Last active
November 8, 2017 09:10
-
-
Save grimabe/7bf59478fa739fcca308cd0fe04e6bef to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Photos | |
class AssetsHelper { | |
class func addAsset(image: UIImage, completion: @escaping (_ identifier: String?) -> Void) { | |
var identifier: String? | |
PHPhotoLibrary.shared().performChanges({ | |
let request = PHAssetChangeRequest.creationRequestForAsset(from: image) | |
identifier = request.placeholderForCreatedAsset?.localIdentifier | |
}) { success, error in | |
guard success == true, | |
let identifier = identifier else { | |
completion(nil) | |
return | |
} | |
completion(identifier) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment