ios - iOS Swift 中解析密码重置错误

标签 ios swift parse-platform password-recovery

我正在使用下面的代码进行密码重置,如解析文档中声明的:https://parse.com/docs/ios/guide#users-resetting-passwords 但是我收到错误:“无法使用类型为 (string (bool!,nserror!)->Void) 的参数调用“requestPasswordResetForEmailInBackground”

我使用的代码是:

  var emailVar = emailField.text
    PFUser.requestPasswordResetForEmailInBackground(emailVar) { (success: Bool, error: NSError!) -> Void in

        if (error == nil) {

            let alertView = UIAlertController(title: "Password recovery e-mail sent", message: "Please check your e-mail inbox for recovery", preferredStyle: .Alert)
            alertView.addAction(UIAlertAction(title: "Ok", style: .Default, handler: nil))
            self.presentViewController(alertView, animated: true, completion: nil)

        }else {

            let alertView = UIAlertController(title: "Could not found your e-mail", message: "There is no such e-mail in our database", preferredStyle: .Alert)
            alertView.addAction(UIAlertAction(title: "Ok", style: .Default, handler: nil))
            self.presentViewController(alertView, animated: true, completion: nil)

        }
    }

最佳答案

在新的解析API中,错误更改为可选值,使用如下:

PFUser.requestPasswordResetForEmailInBackground(emailVar) {
        (success: Bool, error: NSError?) -> Void in

}

关于ios - iOS Swift 中解析密码重置错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31200978/

相关文章:

ios - Swift iOS - 如何设置 UIView 的高度 anchor <= 到标签的固有文本大小? 'NSLayoutConstraint' 不可转换为 'Bool'

ios - 透明的 UITableViewHeaderFooterView

ios facebook sdk v3.11 共享对话框发布按钮已禁用

ios - 重建模型时 Xcode 提示将 swift 与 objective c 桥接

ios - 图形请求,从参数中检索字典值

ios - Xcode 找不到其他项目的头文件

swift - 使用 tableView 单元格中的自动布局实现 TextView 的自动高度

objective-c - parse.com 云编码从 Objective C 到 Swift 的转换

ios - 无法通过 PFUser currentuser 写入非当前用户对象

ios - 只允许 2 个用户从公共(public)类读取一个对象