I am a new programmer. I started learning swift 2.0 without objective c, which I guess was a mistake.
I am trying to integrate quickblox into my swift app, however this line of code is really confusing me. I was wondering if someone could give me a hand
- (void (^)(QBResponse *response, QBUUser *user))successBlock
{
return ^(QBResponse *response, QBUUser *user) {
// Login succeeded
};
}
The function returns a block function, which gets two parameters: the response and the user. Its return type is void.
So in swift, it should basically look like this:
func successBlock() -> (QBResponse, QBUUser) -> Void {
return { (response, user) in
//Login succeeded.
}
}
It could also be converted to a computed property as it does not have side effects and does not rely on any parameters:
var successBlock: (QBResponse, QBUUser) -> Void {
return { (response, user) in
//Login succeeded.
}
}