远程写入 .plist 文件 iPhone SDK
我想知道是否有一种方法可以远程写入存储在我的服务器上的 plist 文件。文件所在的目录具有写访问权限,但我似乎无法推送新数据。这是我的代码:
NSString *accountURL = [NSString stringWithFormat:@"http://www.mywebsite.com//%@.plist",txtUsername.text];
NSURL *url = [NSURL URLWithString:accountURL];
NSMutableDictionary *account = [[NSMutableDictionary alloc] initWithContentsOfURL:url];
[account setObject:@"TEST" forKey:@"LastLogin"];
if ([account writeToURL:url atomically:NO]){
NSLog(@"saved");
}else{
NSLog(@"not saved");
}
plist 文件存在,因为我可以毫无问题地读取它。我只是无法写入文件。
另一方面,如果帐户存储在我的服务器上,这是否对 AppStore 友好?
I am wondering if theres a way to remotely write to a plist file stored on my server. The directory the file is located has write access, but i cannot seem to push the new data. Heres my code:
NSString *accountURL = [NSString stringWithFormat:@"http://www.mywebsite.com//%@.plist",txtUsername.text];
NSURL *url = [NSURL URLWithString:accountURL];
NSMutableDictionary *account = [[NSMutableDictionary alloc] initWithContentsOfURL:url];
[account setObject:@"TEST" forKey:@"LastLogin"];
if ([account writeToURL:url atomically:NO]){
NSLog(@"saved");
}else{
NSLog(@"not saved");
}
The plist file exists because I can read from it with no problem. I just cannot write to the file.
On another note, is this even AppStore-friendly if the accounts will be stored on my server?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您需要像这样解析此 Web 服务,并需要实现解析器的委托方法。
然后你就可以在服务器上编写plist文件了。另外,你还可以使用POST、PUT等解析方法,也可以向服务器发送同步请求,这取决于你。
You need to parse this web service like this and need to implement the delegate methods of parser.
And then you would be able to write the plist file on server. Moreover, you could also use the method for parsing like POST, PUT and you can also send aSynchronousRequest to the server, that depends upon you.
只读很容易。一旦你开始写东西,你就会获得以下权限:服务器、应用程序、用户。
要解决您的问题,您需要创建一个 Web 服务来验证用户和应用程序、检查权限并保存文件。通常,它是一个从 iPhone 应用程序接受 POST 或 PUT 的服务器(类似于浏览器的上传操作)
Read-only is easy. As soon as you get into writing something you get into permissions for: server, application, user.
To solve your problem you need to create a web service that will authenticate the user and application, check permissions and save the file. Typically it would be a server accepting a POST or PUT from your iPhone app (similar to what browsers do for upload)