我是 iOS 开发的新手,我想知道 .plist
文件在 iOS 中是如何工作的。任何人都可以通过举例说明如何在 .plist
中读取和写入数据来帮助我吗?
最佳答案
是的:
NSString *rootPath = [[NSBundle mainBundle] bundlePath];
NSString *pListPath = [rootPath stringByAppendingPathComponent:@"Settings.bundle/Root.plist"];
NSDictionary *pList = [NSDictionary dictionaryWithContentsOfFile:pListPath];
写入文件也不是太难:
NSDictionary *dict;
NSData *data = [NSPropertyListSerialization dataWithPropertyList:dict format:NSPropertyListXMLFormat_v1_0 options:0 error:&error];
[data writeToFile:self.saveToPath atomically:YES];
关于iphone - .plist 文件如何在 iOS 中工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9634390/