gpt4 book ai didi

error-handling - 错误代码句柄不起作用

转载 作者:行者123 更新时间:2023-12-03 08:51:26 25 4
gpt4 key购买 nike

我正在编写教程,该人员正在使用Swift 2 Xcode 7和Firebase。

她有一个错误处理程序,因此当它返回代码时,它将继续进行下一步。

当我尝试它时,它将不允许使用语法error.code,因此当未注册用户时,它将返回错误代码-8。

下面是代码,我尝试了另一种方法(错误!NSError)。

祝一切顺利
托尼·梅里特

if error != nil {
print(error)

if error.code == STATUS_ACCOUNT_NONEXIST {
FIRAuth.auth()?.createUser(withEmail: email, password: password) { (result, error) in

最佳答案

我能够在另一篇文章的帮助下解决这个问题。

我将代码更改为。

    if error != nil {

print(error)


let code = (error as! NSError).code

if code == STATUS_ACCOUNT_NONEXIST

STATUS_ACCOUNT_NONEXIST在其他区域设置为17011。

关于error-handling - 错误代码句柄不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39903011/

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