我是 iPhone 开发新手。我想知道是否有任何示例 Objective-C 代码可以通过从网络服务器获取数据来在运行时创建 plist,并且我想知道数据的格式应该是什么,以便我可以在运行时轻松创建 plist。
非常简单NS词典 http://developer.apple.com/library/ios/#documentation/Cocoa/Reference/Foundation/Classes/nsdictionary_Class/Reference/Reference.html:
#define DOCUMENTS_PATH [NSSearchPathForDirectoriesInDomains(NSDocumentsDirectory, NSUserDomainMask, YES) objectAtIndex:0]
NSDictionary *myDictionary = [self parseWebResult];
// note that myDictionary must only contain values of string,
// int, bool, array (once again containing only the same types),
// and other primitive types (I believe NSDates are valid too).
[myDictionary writeToFile:[DOCUMENTS_PATH stringByAppendingPathComponent:@"myDict.plist"] atomically:YES];
// reading in the dictionary
myDictionary = [NSDictionary dictionaryWithContentsOfFile:[DOCUMENTS_PATH stringByAppendingPathComponent:@"myDict.plist"]];
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)