Jon*_*Jon 6 iphone xcode objective-c plist nsarray
我正在尝试从我的.Plist中的数组加载我的数组,但它无法正常工作.
plist看起来像这样:

这是我正在使用的代码:
NSString *path = [[NSBundle mainBundle]pathForResource:@"DiseasePropertyList" ofType:@"plist"];
NSMutableArray *rootLevel = [[NSMutableArray alloc]initWithContentsOfFile:path];
self.myArray = rootLevel;
[rootLevel release];
Run Code Online (Sandbox Code Playgroud)
试试这个.请更改文件名.它工作正常.
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *recentFilePath = [documentsDirectory stringByAppendingPathComponent:@"recent.plist"];
NSArray *history = [NSArray arrayWithContentsOfFile:recentFilePath];
Run Code Online (Sandbox Code Playgroud)
你的plist实际上是一本字典.数组是键"Array"的字典对象.您可以通过选择"Array"并切割(CMD-x),然后粘贴到空的plist(CMD v)中,将plist放入Xcode 4中的数组中.
| 归档时间: |
|
| 查看次数: |
8583 次 |
| 最近记录: |