Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iphone SDK:Can write data to plist on Simulator but can't do same thing at Device?

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"];
like image 314
Webber Lai Avatar asked Jan 29 '26 13:01

Webber Lai


1 Answers

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];
}
like image 185
nduplessis Avatar answered Jan 31 '26 05:01

nduplessis



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!