0

I have this Swift function with closures:

static func fetchAccounts(success succeed : @escaping ((_ results:Array<Account>) -> ()),
                                   failure : @escaping ((NSError) -> ()))

I need to use it in an Objective C class, but I don't remember how to cast it to Objective C blocks, regarding block syntax(blocks are empty):

[Account fetchAccounts success:(      ){
    NSLog(@"call back success");
} failure:(     ){
    NSLog(@"call back success");
}]

Many thanks.

Jaydeep Vora
  • 6,085
  • 1
  • 22
  • 40
Froi
  • 39
  • 4

1 Answers1

0

This is how you handle an Objective-C Block in this circumstance:

[someObject doSomethingWithBlock: ^return_type (var_type varName)
{
    //...
}];

This answer to a similar question might help.

And this answer about declaring Objective-C Blocks is a great resource. It's where I got the above listed code.

Jake
  • 2,126
  • 1
  • 10
  • 23