Reputation: 17132
I'm trying to create a backend for an app using the follow tutorial (in Swift!):
https://backendless.com/feature-2-registering-app-users-with-the-user-registration-api/#
But in the registerUser()
function it tells me: expected member name following '.' at the line Types.try({ () -> Void in
Everything else works fine. Even if I delete this function and execute the registerUserAsync()
, the user will be created. So It is not an framework importation issue.
Is it possible, that it is an Swift1/2 Issue? Since the code is in Swift1 (println(...)
)
Any help is appreciated
The Code:
// ViewController.swift
// F2RegisteredUsersSwift
import UIKit
class ViewController: UIViewController {
let APP_ID = "YOUR-APP-ID"
let SECRET_KEY = "YOUR-SECRET-KEY"
let VERSION_NUM = "v1"
var backendless = Backendless.sharedInstance()
override func viewDidLoad() {
super.viewDidLoad()
backendless.initApp(APP_ID, secret:SECRET_KEY, version:VERSION_NUM)
registerUser()
registerUserAsync()
}
func registerUser() {
Types.try({ () -> Void in
var user = BackendlessUser()
user.email = "[email protected]"
user.password = "greeng0blin"
user.setProperty("phoneNumber", object:"214-555-1212")
var registeredUser = self.backendless.userService.registering(user)
println("User has been registered (SYNC): \(registeredUser)")
},
catch: { (exception) -> Void in
println("Server reported an error: \(exception as Fault)")
})
}
func registerUserAsync() {
var user = BackendlessUser()
user.email = "[email protected]"
user.password = "sp1day"
user.setProperty("phoneNumber", object:"214-555-1212")
backendless.userService.registering(user,
response: { (var registeredUser : BackendlessUser!) -> () in
println("User has been registered (ASYNC): \(registeredUser)")
},
error: { (var fault : Fault!) -> () in
println("Server reported an error: \(fault)")
}
)
}
}
Upvotes: 1
Views: 9447
Reputation: 974
You should update this project to Swift 2.0. You can do it via
Edit->Convert->To Latest Swift Syntax…
This will update your code and replace try, catch with 'try', 'catch' I think it will be done because
"try" is a reserved word (used for error handling) in Swift 2.
Upvotes: 2
Reputation: 52622
"try" is a reserved word (used for error handling) in Swift 2. If you have a method or function named "try" in your Swift 1 code, you better rename it.
Upvotes: 3