我是iOS开发的新手,我想知道.plist文件在iOS中是如何工作的.任何人都可以通过给我一个如何读取写入数据的示例来帮助我.plist吗?
对:
NSString *rootPath = [[NSBundle mainBundle] bundlePath];
NSString *pListPath = [rootPath stringByAppendingPathComponent:@"Settings.bundle/Root.plist"];
NSDictionary *pList = [NSDictionary dictionaryWithContentsOfFile:pListPath];
Run Code Online (Sandbox Code Playgroud)
写入文件也不是太难:
NSDictionary *dict;
NSData *data = [NSPropertyListSerialization dataWithPropertyList:dict format:NSPropertyListXMLFormat_v1_0 options:0 error:&error];
[data writeToFile:self.saveToPath atomically:YES];
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4427 次 |
| 最近记录: |