iPhone SDK:可以在Simulator上将数据写入plist,但不能在Device上执行相同的操作吗? [英] iphone SDK:Can write data to plist on Simulator but can't do same thing at Device?

查看:58
本文介绍了iPhone SDK:可以在Simulator上将数据写入plist,但不能在Device上执行相同的操作吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么我可以在模拟器上将信息写入plist

Why I can write information to plist on simulator

但是不能在真正的iPhone/iPod设备上执行此操作吗????

But can't do this on real iphone/ipod device ????

是否存在将.plist文件放入xcode项目的绝对路径?

Is there exist an absolute path to put a .plist file in xcode project ???

感谢所有答复和答复〜

code:这就是我如何从文本字段将文本写入plist

code : this how I write text to plist from textfield

NSString *plistPath = [[NSBundle mainBundle] pathForResource:@"Password" ofType:@"plist"];
NSMutableDictionary *propertyList = [[NSMutableDictionary alloc] initWithContentsOfFile:plistPath];
[propertyList setValue:serialNumber.text forKey:@"serial_number"];

推荐答案

您只能写入应用程序的沙箱目录.下面是一个函数,它将为您的应用返回文档文件夹的路径.

You can only write to your application's sandbox directory. Below is a function that will return the path to the Documents folder for you app.

- (NSString *)applicationDocumentsDirectory
{
    return [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject];
}

这篇关于iPhone SDK:可以在Simulator上将数据写入plist,但不能在Device上执行相同的操作吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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