1

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)
    }
}
admdrew
  • 3,790
  • 4
  • 27
  • 39
Tom
  • 790
  • 2
  • 9
  • 32

1 Answers1

1

You probably want to write to pngFileName rather than arrayPaths

qwerty_so
  • 35,448
  • 8
  • 62
  • 86