Swift: NSFileManager's – fileExistsAtPath:isDirectory: Requires an Absurd UnsafeMutablePointer<ObjCBool> Type

Originator:justin
Number:rdar://22890985 Date Originated:28-Sep-2015 07:04 PM
Status:Open Resolved:
Product:OS X Product Version:Mac OS X 10.11 (15A282b)
Classification:Enhancement Reproducible:Always
 
The NSFileManager has a method called – fileExistsAtPath:isDirectory: that is declared as follows in Swift:

func fileExistsAtPath(_ path: String,
          isDirectory isDirectory: UnsafeMutablePointer<ObjCBool>) -> Bool

The second argument should just be a simple Bool in Swift, not an UnsafeMutablePointer<ObjCBool>, which makes the code required to call this method needlessly long and complex.

Comments

Be aware that the second argument is a "return value" set by the method to true if the file is a directory, so it needs to be a pointer and cannot be a simple Bool!

By f.vadicamo at Oct. 23, 2015, 10:51 a.m. (reply...)

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!