【发布时间】:2015-08-26 00:16:17
【问题描述】:
我正在尝试为解析的“无效登录参数(代码:101,版本:1.8.1)”创建自定义字符串。以下是在自定义警报视图中显示此错误代码的代码:
PFUser.logInWithUsernameInBackground(userName, password: passWord) {
(user, error: NSError?) -> Void in
if user != nil || error == nil {
dispatch_async(dispatch_get_main_queue()) {
self.performSegueWithIdentifier("loginSuccess", sender: self)
}
} else {
dispatch_async(dispatch_get_main_queue()) {
self.activityIND.stopAnimating()
let errorView:String = error!.userInfo!["error"] as! String
self.failedMessage(errorView)
}
}
}
}
func failedMessage(theMessage: String){
let myAlert = SCLAlertView().showError("Woah There", subTitle: theMessage, closeButtonTitle: "Got It")
myAlert.alertview.contentView.backgroundColor = UIColor(red:1.0, green:0.18, blue:0.18, alpha:1.0)
myAlert.alertview.circleBG.backgroundColor = UIColor(red:1.0, green:0.18, blue:0.18, alpha:1.0)
myAlert.alertview.labelTitle.textColor = UIColor.whiteColor()
myAlert.alertview.contentView.layer.borderColor = UIColor(red:1.0, green:0.18, blue:0.18, alpha:1.0).CGColor
myAlert.alertview.viewText.textColor = UIColor.whiteColor()
myAlert.alertview.viewText.backgroundColor = UIColor(red:1.0, green:0.18, blue:0.18, alpha:1.0)
}
现在我创建了一个 localizable.strings 文件并添加了以下字符串
"error" = "something isn't right, check the username and password fields"
现在我几乎可以肯定这是不正确的格式,因为我以前从未使用过可本地化的字符串,但你明白了。我试图用我的自定义消息伪装那个简单的“无效登录参数”消息。使用我的 localizable.strings 文件,我该怎么做?
【问题讨论】:
标签: ios swift localization internationalization