我將Xcode更新爲6.3,並發現我的代碼中存在一些新的Swift 1.2新錯誤。Swift 1.2中令我困惑的更改
user.signUpInBackgroundWithBlock {
(success:Bool!, error:NSError!) -> Void in
if !(error != nil) {
println("sign up successfully")
var loginAlert: UIAlertController = UIAlertController(title: "Sign Up", message: "Sign Up Succeeded", preferredStyle: UIAlertControllerStyle.Alert)
self.presentViewController(loginAlert, animated: true, completion: nil)
loginAlert.addAction(UIAlertAction(title: "Okay", style:
我得到這個錯誤:
Cannot invoke signUpInBackgroundWithBlock with an argument list of type ((Bool!, NSError!) -> void)
我怎樣才能解決這個問題?
另外一個
@IBAction func endend(sender: AnyObject) {
if (PFUser.currentUser() == nil) {
PFUser.logInWithUsernameInBackground(usernameTextField.text, password: passwordTextField.text){
(user:PFUser!, error:NSError!) -> Void in
if user != nil {
println("login chenggong")
var tlvc = TimelineViewControllerTableViewController()
self.presentViewController(tlvc, animated: true, completion: nil)
}
else {
println("failed")
}
}
}
}
我得到這個錯誤:
「UITextField」 does not have member named 「text」.
而且我得到了3個錯誤,大約}
,它說
Expected 「,」 separator.
Expected expression in list of expressions.
Expected 「)」 in expressions.
我可以跑到我的應用程序斯威夫特以前1.2,但現在...
'如果(誤差=零!)'會更理智地寫成'如果錯誤== nil'你能否也向我們展示了'signUpInBackgroundWithBlock'方法的宣言!? – Sulthan
你在用戶名後缺少冒號 – Sulthan
我找不到你剛剛提到的用戶名。但感謝您的幫助! –