-1

我正在准备一个 ios 应用程序。我正在使用以下代码

NSString * yol=[[NSBundle mainBundle]pathForResource:@"TavsiyeKitapAile" ofType:@"plist"];


NSDictionary * tka = [XMLReader dictionaryForXMLData:[NSData dataWithContentsOfURL:[NSURL URLWithString:@"http://www.bahcevan.org/kat.php?kat=64"]] error:nil];

[tka writeToFile:yol atomically:YES];

NSMutableDictionary * dic = [[NSMutableDictionary alloc]initWithContentsOfFile:yol];

它在模拟器上运行良好,但是当我打开它时,我看不到数据。什么都没有。我认为它与捆绑有关,但我无法解决。

4

2 回答 2

2

您无法写入设备包,您的设备包是只读的,如果您想保存/写入某些内容,则必须将其写入文档目录。

于 2012-11-24T11:42:19.237 回答
-1

i found the solution, it is using the directory "Documents", i used following code insted of first one :)

NSArray *paths = NSSearchPathForDirectoriesInDomains(
                                                     NSDocumentDirectory,
                                                     NSUserDomainMask, YES
                                                     );

NSString *documentsDirectory = [paths objectAtIndex:0];

NSURL *yol = [NSURL fileURLWithPath:[documentsDirectory
                                     stringByAppendingString:@"/TavsiyeKitapAile.plist"]];

NSDictionary * tka = [XMLReader dictionaryForXMLData:[NSData dataWithContentsOfURL:[NSURL URLWithString:@"http://www.bahcevan.org/kat.php?kat=64"]] error:nil];

[tka writeToURL:yol atomically:YES];


NSMutableDictionary * dic = [[NSMutableDictionary alloc]initWithContentsOfURL:yol];
于 2012-11-24T22:16:09.960 回答