我如何使用PromiseKit / Photos任何一个例子?我无法找到任何特别是照片的文档。
我已经实现如下,我可以收到请求
_ = PHPhotoLibrary.requestAuthorization().then(execute: { (status) -> Void in print(status.rawValue) })
任何比上述实施更好的方法都会有所帮助。
答案 0 :(得分:2)
您走在正确的道路上,您实施的方式是正确的,您也可以查看以下代码
http://localhost/quiz/admin/edit_category.php?id=8
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:
//…
}
}