Reputation: 3
I'm implemanting in an iphone app a .plist file that contain some initial parameters that i'll use later in the app, i create a NSMutableArray myArray with a NSMutableDictionary with some keys then i create the file:
NSArray * paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString * documentsDirectory = [paths objectAtIndex:0];
NSString *filePath = [documentsDirectory stringByAppendingString:@"Initial.plist"];
[myArray writeToFile:filePath atomically:YES];
i acccess the content of this file as:
NSMutableArray *temp= [[NSMutableArray alloc]initWithContentsOfFile:filePath];
everthing works fine in the simulator but when i run a test in a device the content of temp always is null, i don't have any idea why i get a nil Array maybe i'm doing somthing wrong accessing the file.
Upvotes: 0
Views: 242
Reputation: 27601
What's the value of filePath
on the simulator, and on the device?
Use of stringByAppendingString
seems odd to me in this case -- shouldn't that be stringByAppendingPathExtension
instead? I would guess that it's missing a "/" in the path because of that, but you say it works on the simulator...
Upvotes: 1