What is the best way to get document directory path in iOS8

The following is a common way to get the application document catalog directory.

Option 1)

- (NSURL *)applicationDocumentDirectory {
  NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, true);
  NSString *documentPath = [paths objectAtIndex:0];
  NSURL *url = [NSURL fileURLWithPath:documentPath];
}

But Apple Documentation suggests using the following in iOS8:

Option (2)

- (NSURL *)applicationDocumentsDirectory
{
    return [[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory    
                                                   inDomains:NSUserDomainMask] lastObject];
}

In both cases, I get the same value.

So there is confusion here. should i use the second option or not? is this a mandatory change in iOS 8?

Please give your suggestions?

+4
source share
1 answer

I think the second option should be better, read this answer fooobar.com/questions/451023 / ...

+3
source

Source: https://habr.com/ru/post/1569278/


All Articles