Reputation: 13998
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDicrectory = [paths objectAtIndex:0];
NSString *filePath = [documentsDicrectory stringByAppendingPathComponent:@"libdata.xml"];
NSString *xmlString = [NSString stringWithContentsOfFile:filePath encoding:NSUTF8StringEncoding error:NULL];
I stored an xml file (not small about 140k size) in resources folder in xcode and tried to load the xml file to parse it. But xmlString gets nil. What is wrong with this code? Thanks in advance
Upvotes: 0
Views: 1370
Reputation: 54020
Use the NSBundleClass:
NSString * filePath = [ [ NSBundle mainBundle ] pathForResource: @"libdata" ofType: @"xml" ];
Upvotes: 2