从.Plist加载数组 [英] Loading Array From .Plist
本文介绍了从.Plist加载数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试从.Plist中的数组加载数组,但无法正常工作.
I'm trying to load my array from an array in my .Plist but its not working.
plist看起来像这样:
The plist looks like this:
这是我正在使用的代码:
This is the code I'm using:
NSString *path = [[NSBundle mainBundle]pathForResource:@"DiseasePropertyList" ofType:@"plist"];
NSMutableArray *rootLevel = [[NSMutableArray alloc]initWithContentsOfFile:path];
self.myArray = rootLevel;
[rootLevel release];
推荐答案
尝试一下.请更改文件名. 效果很好.
Try this. Please change file name. It works fine.
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *recentFilePath = [documentsDirectory stringByAppendingPathComponent:@"recent.plist"];
NSArray *history = [NSArray arrayWithContentsOfFile:recentFilePath];
这篇关于从.Plist加载数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文