PNG Image not saved to documents directory

704 views Asked by At

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)
    }
}
1

There are 1 answers

0
qwerty_so On BEST ANSWER

You probably want to write to pngFileName rather than arrayPaths