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

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

createFileAtPath stopped working after upgrade to Swift 2 and now it gives the following error:

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

1

1 Answers

3
votes

Unfortunately NSFileManager has no creation method that operates on a NSURL. In my code I try to avoid String for path usage and this is one of the rare places I still fall back to a path using the NSURL.path property

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