i am prepararing an ios application. i am using following code
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];
it is working well on simulator but when i open it, i couln't see data. nothing comes. i think it is related with bundle but i couldn't solve it.
您无法写入设备包,您的设备包是只读的,如果您想保存/写入某些内容,则必须将其写入文档目录。
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];
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.