Tom
Tom

Reputation: 802

PNG Image not saved to documents directory

I am trying to load an image from the photo library and save to the phone's document directory, however when I look in the document directory the PNG has not been created. I'm using the following code:

@IBAction func saveLogo(sender: AnyObject) {
    if (pickedImage != nil) {
        var fileName:String = "logo.png"   
        var arrayPaths = NSSearchPathForDirectoriesInDomains(.DocumentDirectory, .UserDomainMask, true)[0] as NSString
        var pngFileName = arrayPaths.stringByAppendingPathComponent(fileName)    
        UIImagePNGRepresentation(pickedImage).writeToFile(arrayPaths, atomically:true)
    }
}

Upvotes: 1

Views: 703

Answers (1)

qwerty_so
qwerty_so

Reputation: 36333

You probably want to write to pngFileName rather than arrayPaths

Upvotes: 1

Related Questions