I sporadically receive an error message
*** Application termination due to the uncaught exception "NSInvalidArgumentException", reason: "Cannot read the file in the file: ///var/mobile/Applications/D743821C-6F34-4E97-8FBA-D7EAD6738E38/Documents/contacts.zip
*** The first roll stack calls: (0x2ef1ef83 0x39799ccf 0x2eb5f7c3 0x2eb5f2dd 0x39c8181f 0x39c87677 0x2eb5f289 0x2eb9897f 0x172cb9 0x17bac3 0x5b769 0x160d99 0x69f2d 0x698cb 0x1709c7 0x17a9a3 0x39c81833 0x39c88ad7 0x39c88d29 0x39dc3bd3 0x39dc3a98) libS ++ abi.dylib: completion with uncaught exception type NSException
The program crashes on a line
Info.uploadTask = [self.session uploadTaskWithRequest:request fromFile:url];
When I look in the device container, I see that the file is not there.
I do not understand
- why exists when checking the path if the file does not exist
why the program does not work, even if it is in the catch try block
NSString *path = file.myPath; if ([[NSFileManager defaultManager] fileExistsAtPath:path]) { @try { NSURL *url = [NSURL fileURLWithPath:path]; Info.uploadTask = [self.session uploadTaskWithRequest:request fromFile:url]; } @catch (NSException *exception) { BLog("error Reading file:%@",path); return; } } else { BLog(@"file not found:%@",path); return; }
source share