Reputation: 1596
I download the pdf file using afnetworking framework then to save file on this path.
NSURL *documentsDirectoryURL = [NSBundle.mainBundle.resourceURL URLByAppendingPathComponent:@"file.pdf"];
when i try to access the file using simulator. it works fine. but when to access on real device.
File at /var/mobile/Applications/40F3BDE0-F4B1-4C85-A32C-FEB08450646A/appname.app/file.pdf does not exist.
I think some sandboxing issue. but how to get rid of this issue. please help. Thanks in advance
Upvotes: 0
Views: 139
Reputation: 42977
App's bundle is read only, you cannot save files to the bundle. Instead you could save it in apps Documents
directory.
- (NSURL *)applicationDocumentsDirectory {
return [[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory
inDomains:NSUserDomainMask] lastObject];
}
NSString *path = [[self applicationDocumentsDirectory].path
stringByAppendingPathComponent:@"fileName.pdf"];
Edit
All the files in the Documents
directory is sharable, that means other apps can access it. So if you put any data that cannot be viewable by the user dont put it documents instead use Library
folder. Read more about here
Upvotes: 1