iphone SDK:Can write data to plist on Simulator bu

2019-01-28 09:52发布

Why I can write information to plist on simulator

But can't do this on real iphone/ipod device ????

Is there exist an absolute path to put a .plist file in xcode project ???

Thanks for all reply and answers ~

code : this how I write text to plist from textfield

NSString *plistPath = [[NSBundle mainBundle] pathForResource:@"Password" ofType:@"plist"];
NSMutableDictionary *propertyList = [[NSMutableDictionary alloc] initWithContentsOfFile:plistPath];
[propertyList setValue:serialNumber.text forKey:@"serial_number"];

1条回答
smile是对你的礼貌
2楼-- · 2019-01-28 10:28

You can only write to your application's sandbox directory. Below is a function that will return the path to the Documents folder for you app.

- (NSString *)applicationDocumentsDirectory
{
    return [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject];
}
查看更多
登录 后发表回答