如何在iOS中更新plist文件 [英] how to update the plist file in ios

查看:493
本文介绍了如何在iOS中更新plist文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个应用程序.为此,我尝试使用以下代码更新plist文件.

I am developing one application.In that i am trying to update the plist file using below code.

 plist_path=[[NSBundle mainBundle]pathForResource:@"Configurationfile" ofType:@"plist"];
 config_dict=[[NSMutableDictionary alloc]initWithContentsOfFile:plist_path];
[config_dict setValue:textField.text forKey:@"ServerURL"];
NSLog(@"%@",config_dict);
[config_dict writeToFile:plist_path atomically:YES];
[config_dict release];

但是它不起作用.但是NSlog显示字典中每个键的正确值.请帮助我如何更新plist文件.

But it's not working.But NSlog showing the correct values for every key in the dictionary.Please help me how to update the plist file.

推荐答案

您无法更新应用捆绑包中的文件.而是将文件复制到工作目录并在那里进行更新.

You cannot update the files within the app bundle. Instead copy the files to a working directory and update them there.

这篇关于如何在iOS中更新plist文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆