0

我使用以下方法将我的主 Bundle(Ressource 文件夹)中的 plist 加载到数组中:

 NSString *path = [[[NSBundle mainBundle] resourcePath]stringByAppendingPathComponent:nomPlist ];
 NSMutableArray *tmpQuestion = [[NSArray alloc] initWithContentsOfFile:path];
 arrayQuestion = [ [NSArray alloc] initWithArray:tmpQuestion]; 
 [tmpQuestion release];

因为我决定更改我的 plist 的内容并且该主包是只读的,所以我怎样才能让这个数组从我的应用程序的 Documents 目录加载 plist??

谢谢大家

4

2 回答 2

0

试试看app的documents目录下的文件是否存在

  • 是:然后使用这个文件
  • 否:这是第一次启动,所以从应用程序包中复制它
于 2010-05-31T12:43:12.787 回答
0

[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0]]将为您提供应用程序的 Documents 目录。首次启动时,用于NSFileManager将 plist 文件从应用程序包复制到文档目录。之后,总是从那里打开它。

于 2010-05-02T00:07:02.753 回答