views:

235

answers:

3

Hi all ! 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 plist from the Documents directory of my app ? ?

thanks to all

A: 

[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.

Ole Begemann
A: 

Yes thanks a lot

but can you tell how do i determine first launch ? ?

Florent
A: 

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
olipion