A tester said that he got this message only once, and I can't seem to reproduce it or figure out how this message appeared. In a nut shell, my application starts a background thread and grabs data from our server. Once we are done downloading the data we store it in an xml file, so we can grab the data from this file incase we shutdown durning the parsing of the xml. Once I am done parsing the xml I delete the file. Here is my code for deleting.
-(void)deleteSavedXmlServerData
{
AppDelegate_Shared* appDelegate = (AppDelegate_Shared*)[[UIApplication sharedApplication] delegate];
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *fileToLoad = [NSString stringWithFormat:@"%@/%@/upload.xml", [paths objectAtIndex:0], appDelegate.userId];
if([[NSFileManager defaultManager] fileExistsAtPath:fileToLoad] == YES)
{
NSError *error = nil;
[[NSFileManager defaultManager] removeItemAtPath:fileToLoad error:&error];
if(error != nil)
{
eNSLog(@"%s Error Parsing old data: %@ info: %@", __PRETTY_FUNCTION__, error, [error userInfo]);
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Problem With Syncing"
message:@"Problem reading in old data."
delegate:nil
cancelButtonTitle:@"ok"
otherButtonTitles:nil];
[alert show];
[alert release];
}
}
}
Everything seems to work perfectly, and it is not a big deal if this file does not get deleted. But I am confused why I would have an issue with deleting this file.
When I checked what the error message was this is what I got this.
-[ServerSync deleteSavedXmlServerData] Error Parsing old data: Error Domain=NSCocoaErrorDomain Code=4 UserInfo=0x11f3ed60 "Operation could not be completed. (Cocoa error 4.)" info: {
NSFilePath = "/var/mobile/Applications/CD181518-512F-4A0E-82ED-C438886E4A1D/Documents/71BD9A11-A604-6001-549C-DF6582F60124/upload.xml";
NSUserStringVariant = Remove;
}
If anyone know why if my file exist and I created it, why I cannot delete it?
Update
The question that confused me the most, is why does the first if statement say the file exist, but the error message that I get from trying to remove the file says that my file does not exist?