I was working on a app which access the user photo library using the PHAssets class method. How would be able to “Access your photos” permission dialog again once the user selects his options Allow or Don't Allow. If the user selects Allow how could we fetch the data at the same time. Second how can we handle Don't Allow option in Swift. Here is the code:
override func viewDidLoad() { super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
let images = PHAsset.fetchAssetsWithMediaType(PHAssetMediaType.Image, options: nil)
let targetSize: CGSize = CGSize(width: 350, height: 480)// target size
let contentMode: PHImageContentMode = PHImageContentMode.AspectFill // content mode
images.enumerateObjectsUsingBlock {
object, index, stop in
let options = PHImageRequestOptions()
options.synchronous = true
options.deliveryMode = .HighQualityFormat
PHImageManager.defaultManager().requestImageForAsset(object as! PHAsset, targetSize: targetSize, contentMode: contentMode, options: options) {
image, info in
self.myCol.append(image)
}
}
ImageCol.store = myCol
}