I\'m trying to access a file to pull a copy into my app so that users can associate it with relevant information. It used to work just fine up until recently, and now I sudd
It turns out there's a "using" function that tells the app its accessing files outside of it's sandbox. The methods startAccessingSecurityScopedResource and stopAccessingSecurityScopedResource on NSURL need to be wrapped around the code using the url, like so:
BOOL isAcccessing = [url startAccessingSecurityScopedResource];
NSError* error = nil;
NSString *path = [url path];
NSData *data = [NSData dataWithContentsOfFile:path options: 0 error: &error];
if(data == nil) {
NSLog(@"Failed to read file, error %@", error);
}
if (isAccessing) {
[url stopAccessingSecurityScopedResource];
}
I'm not sure if there's anything specific to iOS 13 that requires this when it didn't previously, but that is the only real change between it working and not working.