gpt4 book ai didi

ios - 如何使用 PromiseKit/照片?

转载 作者:可可西里 更新时间:2023-11-01 01:25:38 24 4
gpt4 key购买 nike

我如何使用 PromiseKit/Photos 的例子?我找不到特别是照片的任何文档。

我已经像下面这样实现了并且我能够接收到请求

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

任何比上述实现更好的东西都会有所帮助。

最佳答案

你在正确的道路上,你实现的方式是正确的,你也可以检查下面的代码

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:
//…
}
}

关于ios - 如何使用 PromiseKit/照片?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41689790/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com