I use to load plist which are in my main Bundle (Ressource folder) into an array using :
NSString *path = [[[NSBundle mainBundle] resourcePath]stringByAppendingPathComponent:nomPlist ];
NSMutableArray *tmpQuestion = [[NSArray alloc] initWithContentsOfFile:path];
arrayQuestion = [ [NSArray alloc] initWithArray:tmpQuestion];
[tmpQuestion release];
since i decide to change the content of my plist and that main bundle is read only how can i make this array loading pli开发者_高级运维st from the Documents directory of my app ? ?
thanks to all
[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0]]
will get you your app's Documents directory. On first launch, use NSFileManager
to copy the plist file from your app's bundle to the documents directory. Afterwards, always open it from there.
Try to see if the file in app's documents directory exist
- YES : then use this file
- NO : this is the first launch, so copy it from the apps's bundle
精彩评论