createFileAtPath 不再接受 NSURL

createFileAtPath not accepting NSURL anymore

    let singleImage = "current.jpg"
    let path = NSURL(fileURLWithPath: NSTemporaryDirectory()).URLByAppendingPathComponent(singleImage)
    let fileManager = NSFileManager.defaultManager()

    fileManager.createFileAtPath(path, contents: imageDataFromURL, attributes: [:])

createFileAtPath 在升级到 Swift 2 后停止工作,现在出现以下错误:

Cannot convert value of type 'NSURL' to expected argument type 'String'

不幸的是 NSFileManager 没有在 NSURL 上运行的创建方法。在我的代码中,我尽量避免使用 String 路径,这是我仍然使用 NSURL.path 属性

的少数地方之一
fileManager.createFileAtPath(pathURL.path!, contents: imageDataFromURL, attributes: [:])