2017-01-17 4 views
1

Wie kann ich PromiseKit/Photos ein beliebiges Beispiel verwenden? Ich kann keine Dokumente speziell für Fotos finden.Wie benutzt man PromiseKit/Fotos?

Ich habe wie unten ausgeführt, und ich bin in der Lage Anfrage

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

Alles, was besser als über die Umsetzung hilfreich wäre zu erhalten.

Antwort

2

Sie auf dem richtigen Weg sind, so, wie Sie richtig implementiert ist, und Sie können auch

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: 
    //… 
} 
} 
unten Code überprüfen