Issue in iOS8 document directory
path detection:
Am using following code to store downloaded attachments from my app into documents directory
path.
//-- Store data to documents folder
NSString *resourceDocPath = [[NSString alloc] initWithString:[ [[[NSBundle mainBundle] resourcePath] stringByDeletingLastPathComponent] stringByAppendingPathComponent:@"Documents"]];
NSString *filePath = [resourceDocPath stringByAppendingPathComponent:[NSString stringWithFormat:@"%@",fileName]];
[self.downloadedMutableData writeToFile:filePath atomically:YES];
Using following code to retrieve document form path
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
ios7
simulator & device.ios8
device & also in simulator too.ios8
.application Documents
directory, it works on every iOS version:
- (NSURL *)applicationDocumentsDirectory {
return [[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask] lastObject];
}