Search code examples
iphoneiosbundlensbundle

iphone Simulator and device bundle


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.


Solution

  • 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];