我一直在试图将NSDictionary的plist保存到我的应用程序的Documents文件夹中。我尚未在设备上尝试过,但我希望它能在模拟器上工作以进行测试。 [self createDictionaryFromChoreList]
方法只是从另一个类的一些数据创建一个NSDictionary。我几乎从Web文档复制/粘贴了这段代码,当我查看文件是否已保存时,我发现它不是。这是方法块。Plist没有从字典保存到文档
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *plistName = [[NSString alloc] initWithFormat:@"%@chores.plist", self.firstName];
NSString *path = [documentsDirectory stringByAppendingPathComponent:plistName];
NSDictionary *choresDictionary = [[NSDictionary alloc] initWithDictionary:[self createDictionaryFromChoreList]];
[choresDictionary writeToFile:path atomically:YES];
任何帮助,非常感谢。提前致谢。
-S
是的,这是正确的。 NSDictionary没有打印方法。 – skylerl 2010-01-22 02:43:06