NSFileManager's `createDirectoryAtPath:withIntermediateDirectories:attributes:` documentation is confusing with Swift
| Originator: | moshefromsinai | ||
| Number: | rdar://25684258 | Date Originated: | 04-12-2016 |
| Status: | Open | Resolved: | No |
| Product: | iOS SDK | Product Version: | 7.3 |
| Classification: | Usability | Reproducible: | Always |
The documentation for createDirectoryAtPath:patch withIntermediateDirectories:attributes:error: method of NSFileManager states that the method returns a BOOL value indicating if the operation succeeded. In Swift, this method returns a tuple and throws if it fails. The "Swift way" to use this method is to mark it with try and wrap in a do/catch block. It looks like the swift docs still talk about a boolean return value which doesn't exist. Steps to Reproduce: 1. Use NSFileManager.sharedManager().createDirectoryAtPath... 2. Try to catch a Boolean return value, like so: let success : Bool = NSFileManager.sharedManager().createDir... Expected Results: Either the documentation needs to consider this, or the method should return a Bool. Actual Results: The method returns an empty tuple, and the compiler chokes on this setup. Version: NSFileManager https://developer.apple.com/library/mac/documentation/Cocoa/Reference/Foundation/Classes/NSFileManager_Class/#//apple_ref/occ/instm/NSFileManager/createDirectoryAtPath:withIntermediateDirectories:attributes:error: Notes: Configuration: Xcode 7.3 (7D175) OS X 10.11.4 (15E65)
Comments
Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!