【问题标题】:How to create a new plist in iphone如何在 iphone 中创建一个新的 plist
【发布时间】:2012-02-07 12:18:06
【问题描述】:

早安 如何在 iphone 中创建一个新的 plist?有可能的 请任何人帮助我

提前致谢

【问题讨论】:

  • 早上好?哈哈该死!加州晚上 8 点 32 分!!

标签: iphone plist


【解决方案1】:

您可以通过右键单击项目文件,选择新文件并选择资源来创建属性列表文件 -

你也可以通过这样的代码创建一个属性列表文件-

创建一个新文件 -

#define FilePath                [@"~/Documents/Demo.plist" stringByStandardizingPath]

NSArray *array = [NSArray arrayWithObjects:obj1,obj2,obj3,nil];
NSData *data = [NSPropertyListSerialization dataFromPropertyList:array  format:NSPropertyListXMLFormat_v1_0  errorDescription:nil];
[data writeToFile:FilePath atomically:YES];

读取该 plist 文件 -

NSData *data = [NSData dataWithContentsOfFile:FilePath];
NSPropertyListFormat format;
NSArray *array = [NSPropertyListSerialization propertyListFromData:data mutabilityOption:NSPropertyListImmutable format:&format errorDescription:nil];

obj1 = [array objectAtIndex:0];
obj2 = [array objectAtIndex:1];
obj3 = [array objectAtIndex:2];

【讨论】:

  • 感谢您的回复,非常有用。
  • 如果一个答案对您有帮助,那么您应该接受它,以便它对其他用户也有帮助。
【解决方案2】:

在 xcode 中,

右键 -> 新建文件 -> 资源选项卡 -> 属性列表文件。

【讨论】:

    【解决方案3】:

    智者曾经说过:
    要知道答案,我们必须先知道问题。

    阅读this. 希望这就是你要找的东西。

    编辑:智者,我的意思是我自己。

    【讨论】:

    • 虽然理论上可以回答这个问题,it would be preferable 在这里包含答案的基本部分,并提供链接以供参考。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-02-12
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多