Xcode将html从服务器保存到plist

时间:2012-02-06 08:52:36

标签: html xcode plist

我的服务器上有一个php代码,当它名为mydomain.com/index.php?id=11时,它会创建PList格式。但我必须首先通过浏览器(safari->保存页面)将其保存在我的计算机上,并且必须将后缀从(.html)更改为(.plist),因此所有步骤都是手动完成的。然后它在Xcode中使用。

如何通过在Xcode中调用mydomain.com/index.php?id=11直接下载此代码并另存为.plist ??

谢谢!

1 个答案:

答案 0 :(得分:1)

假设Plist包含一个对象数组,你能够这样做吗?

NSURL *myURL = [NSURL URLWithString:@"http://mydomain.com/index.php?id=11"];
NSArray *myArray = [NSArray arrayWithContentsOfURL:myURL];

//either use the array as it is or save it to file:

NSString *myPath = @"some/path.plist"; 
[myArray writeToFile:myPath atomically:NO];

同样的方法适用于字典。我不认为后缀在这样做时很重要,但我自己没有尝试过。

相关问题