I am using swift PHPhotoLibrary class to save image in photo library. Below is my code:
PHPhotoLibrary.sharedPhotoLibrary().performChanges( {
let assetCreation = PHAssetCreationRequest.creationRequestForAssetFromImage(self.photoView.image!)
let imageData = UIImageJPEGRepresentation((self.photoView?.image)!,1)
let option = PHAssetResourceCreationOptions()
assetCreation.addResourceWithType(PHAssetResourceType.FullSizePhoto, data: imageData!, options: option)
},
completionHandler: {
success, error in
if success {
print("save image success" )
} else {
print(error)
}
})
But I always got this error message: Optional(Error Domain=NSCocoaErrorDomain Code=-1 "(null)") This error was printed by the else line: "print(error)"
Does anyone know what the problem is?