Commit 37086526 by Daniel Dahan

development: converted PhotoLibrary requestAccess call to dispatch delegation…

development: converted PhotoLibrary requestAccess call to dispatch delegation methods and callback on the main thread async
parent 47da25c8
......@@ -62,7 +62,7 @@ public protocol PhotoLibraryDelegate {
/**
A delegation method that is executed when the PhotoLibrary status is updated.
- Parameter photoLibrary: A reference to the PhotoLibrary.
- Parameter status: A reference to the AuthorizationStatus.
- Parameter status: A reference to the PHAuthorizationStatus.
*/
@objc
optional func photoLibrary(photoLibrary: PhotoLibrary, status: PHAuthorizationStatus)
......@@ -214,8 +214,9 @@ extension PhotoLibrary {
- Parameter _ completion: A completion block that passes in a PHAuthorizationStatus
enum that describes the response for the authorization request.
*/
public func requestAuthorization(_ completion: ((PHAuthorizationStatus) -> Void)? = nil) {
public func requestAuthorization(_ completion: (@escaping (PHAuthorizationStatus) -> Void)? = nil) {
PHPhotoLibrary.requestAuthorization { [weak self, completion = completion] (status) in
DispatchQueue.main.async { [weak self, completion = completion] in
guard let s = self else {
return
}
......@@ -243,6 +244,7 @@ extension PhotoLibrary {
}
}
}
}
}
/// Fetch.
......
......@@ -28,7 +28,7 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
import Photos
import UIKit
open class PhotoLibraryController: UIViewController, PhotoLibraryDelegate {
/// A reference to a PhotoLibrary.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment