I have this interface in Objective C that I am trying to call from Swift and it does not seem fall into the completion code. Not sure what I am missing!
@interface WPLogin : NSObject /*! * @brief Logs into the application returning success or failure with an error object. * If login is successful the credential is automatically stored * * @param serverURLString Address to login to * @param username Username to login with * @param password Password for user * @param completion Completion block to be called after attempting login */ - (void)loginToURL:(NSString *)serverURLString withUsername:(NSString *)username password:(NSString *)password completion:(void (^)(WPLoginStatus success, NSError * error))completion; @end the calling function from Swift looks like this...
var uid = "test" var pwd = "test" var url = "http://www.google.com" var loginAuth = WPLogin(); loginAuth.loginToURL(url, withUsername: uid, password: pwd, completion: { (status:WPLoginStatus, error:NSError!) -> Void in println("Inside Login") }) bridging file
#import <Foundation/Foundation.h> #import <UIKit/UIKit.h> #import "WPLogin.h" version that works in Objective C
if (!self.login) { self.login = [WPLogin new]; } [self.login loginToURL:url withUsername:uid password:pwd completion:^(WPLoginStatus status, NSError *error) { NSLog(@"complete"); }];