开发者

how can i read from the documents directory in the iphone at run time?

开发者 https://www.devze.com 2022-12-13 16:55 出处:网络
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'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 a开发者_JS百科ccessing the file.


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

0

精彩评论

暂无评论...
验证码 换一张
取 消