解析目标 - C到Swift iOS

Ste*_*Fox 1 xcode ios swift

我在尝试将Objective-C代码更改为Swift时遇到了麻烦.这与Parse框架有关.如果有人知道如何在Swift中编写以下代码,它将对我有很大帮助.

 [user signUpInBackgroundWithBlock:^(BOOL succeeded, NSError *error) {
    if (!error) {
        //The registration was successful, go to the wall
        [self performSegueWithIdentifier:@"SignupSuccesful" sender:self];

    }
Run Code Online (Sandbox Code Playgroud)

Mes*_*ani 6

[NSObject:Anyobject]?没有成员名为subscript的parse编译错误会被抛出.

代码应该是这样的,因为userInfor可能是零.

user.signUpInBackgroundWithBlock {
    (succeeded: Bool!, error: NSError!) -> Void in
    if !(error != nil) {
        // Hooray! Let them use the app now.
    } else {
        if let errorString = error.userInfo?["error"] as? NSString {
            println(errorString)
        }
    }
}
Run Code Online (Sandbox Code Playgroud)