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)
}
}
You probably want to write to
pngFileName
rather thanarrayPaths