1

As most people I'm in the process of converting an existing app over to swift, and there are some features that can't be directly converted so instead I had to copy a few Objective-C classes over and setup a Bridging Header. All of this is done and I can call the functions, but when I call them I can't figure out how to include the callback and get the values from the callback from this method. Below is what I got so far.

This is the typedef and method from the Objective-C file

typedef void (^DictionaryAndStatusRecievedCallBack)(BOOL status, NSDictionary *dictionary);
-(void)verifyLoginCredentialsWithLoginName:(NSString *)loginName Passphrase:(NSString *)passPhrase callback:(DictionaryAndStatusRecievedCallBack)callback;

And here's how I'm calling it in the swift file

var serviceManager : MobileServiceManager = MobileServiceManager()
typealias onCompleteBlock = (status:Bool?, values:NSDictionary?)->Void
serviceManager.verifyLoginCredentialsWithLoginName("username", passphrase: "password", callback: ??)

I can't seem to figure out what to put in the callback area, I was trying a type alias since I saw another article mention that but I still couldn't get that to work either.

1 Answer 1

4
var serviceManager : MobileServiceManager = MobileServiceManager()
serviceManager.verifyLoginCredentialsWithLoginName("username", passphrase: "password", callback: { (status, values) in  
/* Your code*/ })
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks, it's simple once I see it and makes sense I just couldn't figure out how to get there at first.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.