hi all, i've read several thread for this question but unfortunatly not found the answer to my problem :(
i have a xml file in resource folder, and i need just to re-write the same file; the app logic is:
- display data loaded from file
- add new data to the same file
for read a file my code is:
NSString *filePath = [[NSBundle mainBundle] pathForResource:@"myfile" ofType:@"xml"];
NSData *dataXml=[NSData dataWithContentsOfFile:filePath];
for re-write the same file:
NSString *myDataString = @"?xml version=""1.0"" encoding=""UTF-8""?";
NSString *path = [[NSBundle mainBundle] pathForResource:@"myfile" ofType:@"xml"];
BOOL ok=[myDataString writeToFile:path atomically:YES encoding:NSUnicodeStringEncoding error:nil];
For read works fine, but when i try to write, the file is not updated, but it was created another one in another folder, i've tested this in the simulator noting that an app is in a folder like this:
Users/user/Library/Application Support/iPhoneSimulator/Users/Applications/05279766-7B2C-4FC0-BFB0-D87A158A3337/
where there are 3 folder (Documents,tmp,Libary) and the bundle file .app (where there is my xml file)
My question are: is my logic wrong? in wich way are managed app folders in the device??
thanks in advance and sorry for the long thread!