2

How can I use PromiseKit/Photos any example? I am not able to find any docs for Photos in particular.

I have implemented like below and i am able to receive request

_ = PHPhotoLibrary.requestAuthorization().then(execute: { (status) -> Void in print(status.rawValue) })

Anything better than above implementation would be helpful.

Parth Adroja
  • 13,198
  • 5
  • 37
  • 71

1 Answers1

2

You are on the right path, the way you implemented is correct and you can check below code also

http://promisekit.org/docs/

PHPhotoLibrary.requestAuthorization().then { authorized in
print(authorized)  // => true or false
}


PHPhotoLibrary.requestAuthorization().then { authorized -> Void in
guard authorized else { throw MyError.unauthorized }
// …
}.catch { error in
UIAlertView(/*…*/).show()
}

PHPhotoLibrary.requestAuthorization().then { authorized -> Promise in

guard authorized else { throw MyError.unauthorized }

// returning a promise in a `then` handler waits on that
// promise before continuing to the next handler
return CLLocationManager.promise()

// if the above promise fails, execution jumps to the catch below

}.then { location -> Void in

// if anything throws in this handler execution also jumps to the `catch`

}.catch { error in
switch error {
case MyError.unauthorized:
    //…
case is CLError:
    //…
}
}
Jay Patel
  • 343
  • 2
  • 19