-1

I'm trying to call a completion handler but it's never called. I'm doing something wrong ?

I see the first NSLog ("Enter in my second funcition"), but the second NSlog ("completion handler") never apears in my console.

Here is the definition of the function and the caller with completion

- (void)myFirstFunction:(BOOL)selected numberOfBrothers:(int)brothers completion:(void (^)(void))completion

- (void)mySecondFunction
{
    NSLog(@"Enter in my Second function");
   [self myFirstFunction:true
        numberOfBrothers:1
        completion:^{
           NSLog(@"COMPLETION HANDLER");
        }];

}

- (void)myFirstFunction:(BOOL)selected numberOfBrothers:(int)brothers completion:(void (^)(void))completion
{
  NSLog(@"Enter in my First function");
}

thank you

Kargol
  • 113
  • 9
  • 2
    maybe myFirstFunction never actually calls the completion handler. Hard to say without seeing its implementation – Scriptable Nov 21 '19 at 09:14
  • @Scriptable sorry I forgot to write the implementation of First function in the post. I edited the post and now you can see it. – Kargol Nov 21 '19 at 09:49
  • 1
    It's unclear, but in `myFirstFunction` implementation you should do at some point `completion();` – Larme Nov 21 '19 at 09:51

1 Answers1

1

Your first function does not call the completion.

- (void)myFirstFunction:(BOOL)selected numberOfBrothers:(int)brothers completion:(void (^)(void))completion
{
     NSLog(@"Enter in my First function");
     completion();
}
Scriptable
  • 19,402
  • 5
  • 56
  • 72
  • Thank You !! it works !!! I don't know that the function needs to call the completion handler. I'm feeling so stupid :) ths !! – Kargol Nov 21 '19 at 10:19