【发布时间】:2023-03-08 16:30:02
【问题描述】:
我使用 Parse 作为我的应用程序的后端。 我目前正在处理寄存器视图,我遇到了这个问题。 这是我的代码:
user.signUpInBackgroundWithBlock {
(succeeded: Bool!, error: NSError!) -> Void in
if error == nil {
// Hooray! Let them use the app now.
} else {
var errorCode = error.userInfo!["error"] as NSString
var alertController = UIAlertController(title: "Error", message: errorCode, preferredStyle: .Alert)
var okButton = UIAlertAction(title: "Ok", style: .Default, handler: nil)
alertController.addAction(okButton)
self.presentViewController(alertController, animated: true, completion: nil)
}
}
好的,如您所见,如果出现问题,将创建一个 NSError 并将其存储在变量 error 中。现在默认情况下,存储在那里的任何错误都是小写。
当我不知道它会是什么时,我如何将字符串的开头大写。 例如,当前字符串将类似于 '用户名 bob2211 已被占用' 我在寻找什么 '用户名 bob2211 已被占用。'
任何帮助将不胜感激。
【问题讨论】:
标签: ios swift parse-platform