use*_*112 5 ios parse-platform swift
在注册过程中,用户可能会导致多个错误,例如已经使用的用户名,无效的电子邮件地址等...
Parse在错误对象中返回所有需要的信息,请参阅http://parse.com/docs/dotnet/api/html/T_Parse_ParseException_ErrorCode.htm
我无法找到的是如何使用它们,例如如何访问它们以编写开关以捕获所有可能性:
user.signUpInBackgroundWithBlock {
(succeeded: Bool!, error: NSError!) -> Void in
if error == nil {
// Hooray! Let them use the app now.
self.updateLabel("Erfolgreich registriert")
} else {
println(error.userInfo)
}
}
Run Code Online (Sandbox Code Playgroud)
如何切换可能的错误代码?请指教谢谢!
一个NSError也有一个叫做财产code.该代码包含您需要的错误代码.所以你可以使用该代码创建一个switch语句:
user.signUpInBackgroundWithBlock {
(succeeded: Bool!, error: NSError!) -> Void in
if error == nil {
// Hooray! Let them use the app now.
self.updateLabel("Erfolgreich registriert")
} else {
println(error.userInfo)
var errorCode = error.code
switch errorCode {
case 100:
println("ConnectionFailed")
break
case 101:
println("ObjectNotFound")
break
default:
break
}
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4801 次 |
| 最近记录: |