从日志我的路径看起来正确,我的代码是非常标准的.
有任何想法吗?
NSArray *keys = [NSArray arrayWithObjects:@"key1",@"key2",@"key3",nil];NSArray *objects = [NSArray arrayWithObjects:@"value1",@"value2",@"value3",nil];NSDictionary *dictionary = [NSDictionary dictionaryWithObjects:objects forKeys:keys];for (ID key in dictionary) { NSLog(@"key: %@,value: %@",key,[dictionary objectForKey:key]);}Nsstring *path = [[NSBundle mainBundle] pathForResource:@"FormData" ofType:@"pList"];NSLog(@"path:%@",path);[dictionary writetofile:path atomically:YES];解决方法 Johan是对的 – 你不能修改你的应用程序的捆绑包.您有两个保存字典的好选择:文档目录,当用户同步其设备时由iTunes备份;或未备份的缓存目录.如果您不需要备份数据,请将其放在缓存中,这样您就不会减慢同步速度.您可以获得如下所示的目录路径:
Nsstring *documentsDirectoryPath = [NSSearchPathForDirectorIEsInDomains(NSdocumentDirectory,NSUserDomainMask,YES) objectAtIndex:0];Nsstring *cachesDirectoryPath = [NSSearchPathForDirectorIEsInDomains(NSCachesDirectory,YES) objectAtIndex:0];总结
以上是内存溢出为你收集整理的iphone – 编写NSDictionary以支持我的应用程序包全部内容,希望文章能够帮你解决iphone – 编写NSDictionary以支持我的应用程序包所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)