I have an Objective-C wrapper (ObjCWrapper.h and ObjCWrapper.m) with prototype
+ (void) login:(NSString *)username andPassword:(NSString *)password andErrorBlock:(SuccessBlock)errorBlock andSuccessBlock:(SuccessBlock)successBlock;
With typedef
typedef void (^SuccessBlock)(NSString *);
and implementation
+ (void)login:(NSString *)username andPassword:(NSString *)password andErrorBlock:(SuccessBlock)errorBlock andSuccessBlock:(SuccessBlock)successBlock
{
// do stuff like
successBlock(@"test");
}
From my swift view controller (ViewController.swift), I call the login function:
ObjCWrapper.login("abc", andPassword: "abc",
andErrorBlock:
{
(error:String) -> Void in
println();
},
andSuccessBlock:
{
(map:String) -> Void in
println();
}
)
But I get error:
Cannot invoke 'login' with an argument list of type '(String, andPassword: String, andErrorBlock:(String)->void, andSuccessBlock:(String)->void)'
Searching in google says that I am passing some invalid types in the arguments, but I can't find anything wrong in the code. Removing the blocks from the function makes the code work, so I guess it is something related on the way of calling a block function.
Thanks for the help!