关于XCode 4中读取Plist文件为什么会读出空数据
来源:互联网 发布:软文交易系统源码 编辑:程序博客网 时间:2024/05/16 13:50
关于XCode 4中读取Plist文件
本文介绍的是关于XCode 4中读取Plist文件,主要是通过代码来实现内容的需求,内容是通过代码来实现,来看详细内容。
AD:
关于XCode 4中读取Plist文件是本文要介绍的内容,主要介绍的是plist文件图和来获取,内容不多,主要是通过代码来实现。不多说,先来看详细内容。
1. 添加plist文件
2. 代码读取
- // Path to the plist (in the application bundle)
- NSString *path = [[NSBundle mainBundle] pathForResource:
- @"DrinkArray" ofType:@"plist"];
- // Build the array from the plist
- NSMutableArray *array2 = [[NSMutableArray allObjective-C] initWithContentsOfFile:path];
- // Show the string values
- for (NSString *str in array2)
- NSLog(@"--%@", str);
其中array2总是为空,原因:
选中DrinkArray.plist,ctrl + click(或右键,如果有鼠标) open as->source code, 结果如下:
- <?xml version="1.0" encoding="UTF-8"?>
- <!DObjective-CTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
- <plist version="1.0">
- <dict>
- <key>Root</key>
- <array>
- <string>Firecracker</string>
- <string>Lemon Drop</string>
- <string>Mojito</string>
- </array>
- </dict>
- </plist>
解决方法,手工修改成:
- <?xml version="1.0" encoding="UTF-8"?>
- <!DObjective-CTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
- <plist version="1.0">
- <array>
- <string>Firecracker</string>
- <string>Lemon Drop</string>
- <string>Mojito</string>
- </array>
- </plist>
- 关于XCode 4中读取Plist文件为什么会读出空数据
- 关于XCode 4中读取Plist文件
- 关于XCode 4中读取Plist文件
- 在Xcode项目中读取plist文件
- 关于xcode中info.plist文件出错问题
- 关于Xcode中plist文件一些常用设置的使用
- 读取plist文件中的数据
- 单例 从plist文件中读取数据
- java读文件块会读出null,为什么?
- swift读取本地数据元 *.plist 文件
- IOS 读取本地plist类型文件数据
- [数据存储之六]plist文件读取
- iOS中plist,数据写入与读取
- IOS中plist文件内容的读取
- cocos2dx中读取.plist文件方法
- 和kcome的讨论--关于用TBuf8存放文件中读出的数据
- 为什么有时读取XML文件会失败
- 读取plist文件
- MySQL的limit参数
- 解决方案:用户 'sa' 登录失败。原因: 未与信任 SQL Server 连接相关联。
- How To Embedded StyleSheet File with Custom Control.
- 浮点数在内存中的表示
- ubuntu 下安装Eclipse /c c++环境
- 关于XCode 4中读取Plist文件为什么会读出空数据
- C# 在子线程中创建不会阻塞执行的窗口
- Adobe Flash runtimes路线图
- ruby入门_string
- Oracle数据库自治事务详解
- Android中ListView分类
- Google Web App开发指南第四章:构建优秀的Web Apps
- C#中类的属性
- 利用Winpcap的pcap_dump()保存的文件格式