I have this code:
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *path = [documentsDirectory stringByAppendingPathComponent:@"File.plist"];
if([array writeToFile:path atomically: YES]){
NSLog(@"write succesful");}
else {
NSLog(@"write failed");
}
I create in folder Resources a file “File.plist” and I want store an NSMutableArray inside it. When I call this method the message in console is “write succesful” but if I change the path in
NSString *path = [documentsDirectory stringByAppendingPathComponent:@"FileAbstract.plist"];
the message is ever “write succesful? Why? I changed name in path.
In this code you are writing in document directory, which has no relation with the resource folder in the project. You cannot change files in resource folders by running the app. In first run you have written file
File.plistand in 2nd run you have written fileFileAbstract.plist, both in document directory. They have no relation with theFile.plistin resource folder.EDIT: To read the content of the file in an array: