使用iOS SDK在运行时创建plist? [英] Using iOS SDK to create a plist at runtime?

查看:76
本文介绍了使用iOS SDK在运行时创建plist?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是iPhone开发的新手。我想知道是否有任何示例Objective-C代码在运行时通过从Web服务器获取数据来创建plist,我想知道数据的格式应该是什么,以便我可以在运行时轻松创建plist。 p>

I am new to iPhone development. I want to know if there is any sample Objective-C code to create a plist at runtimeby getting data from a webserver and I want to know what the format of the data should be so that I can easily create the plist at runtime.

推荐答案

Plist文件主要由Mac OS X用于以键/值方式存储序列化对象。有多种属性列表文件;在您的情况下,您的服务器应该以xml格式发送数据。从服务器接收数据后,您可以在运行时生成plist。您可以使用以下代码在.plist文件中写入数据。

Plist files are mainly used by Mac OS X to store serialized objects in a key/value manner. There are multiple kinds of Property List files; ASCII, XML and Binary.So in your case your server should send the data in xml format.After receiving the data from server you can generate plist at runtime. You can use the below code to write data in .plist file.

- (void)writeToPlist{
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *filePath = [documentsDirectory stringByAppendingPathComponent:@"WebData.plist"];
NSArray *dataToSave = [dataToSave writeToFile:filePath atomically:YES];
}

请参阅这个和服务器端的这些链接也 link1 link2 link3 < a href =http://sourceforge.net/p/plist/home/synopsis/ =nofollow> link4 。

Please refer this and these links for server side also link1 link2 link3 link4.

这篇关于使用iOS SDK在运行时创建plist?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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