我将 Xcode 更新到 6.3,发现我使用新的 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.
我可以在 Swift 1.2 之前运行我的应用程序,但现在...
最佳答案
以下代码对我有用:
PFUser.logInWithUsernameInBackground(username.text as String!, password: password.text as String!){
(loggedInuser: PFUser?, signupError: NSError?) -> Void in
关于swift - Swift 1.2 中让我困惑的变化,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29591482/