Im trying to implement CometChat in my swift application. I managed to import the Objective-c framework successfully via a bridging header. But now I'm stuck trying to call Objective-C methods from swift.
This is the method from the interface i want to call:
- (void)loginWithURL:(NSString *)siteURL username:(NSString *)username password:(NSString *)password success:(void(^)(NSDictionary *response))success failure:(void(^)(NSError *error))failure; And this is how the method is called from Objective-C:
[cometChat loginWithURL:@"localhost/cometchat/" username:usernameTextField.text password:passwordTextField.text success:^(NSDictionary *response) { NSLog(@"SDK log : Username/Password Login Success %@",response); [self handleLogin]; } failure:^(NSError *error) { NSLog(@"SDK log : Username/Password Login Error%@",error); [self handleLoginError:@[@0,error]]; }]; So far i have this:
cometChat.loginWithURL("localhost/cometchat/", username: EmailField.text, password: PasswordField.text){ (success: [NSDictionary], failure:NSError) in { println("did i make it here?") } } The problem is, it says that there is missing argument "success", but its a mystery to me how it can be an argument, when it clearly returns the response. I want to know how to put together this method call. I also used the objectivec2swift converter, but it wasn't any help. Also, i have no clue what the @ means before the @[@0,error]
I know its a beginners question, but i already wasted a whole day on this, since i couldn't find any tutorials on how to call such "complex" Obj-C methods from swift.