Search code examples
iosobjective-cnsfilemanager

Need assistance regarding create directory methods on NSFileManager


NSFileManager has two methods to create directory, one ask for path and another ask for url. What url is for? Urls are for network but I don't see any network stuff in doc.

createDirectoryAtPath:withIntermediateDirectories:attributes:error:
createDirectoryAtURL:withIntermediateDirectories:attributes:error:

Solution

  • The answer is contained at the same link:

    The NSFileManager class supports both the NSURL and NSString classes as ways to specify the location of a file or directory. The use of the NSURL class is generally preferred for specifying file-system items because they can convert path information to a more efficient representation internally. You can also obtain a bookmark from an NSURL object, which is similar to an alias and offers a more sure way of locating the file or directory later.