Custom completion block for my own method [duplicate]

1) Define your own completion block,

typedef void(^myCompletion)(BOOL);

2) Create a method which takes your completion block as a parameter,

-(void) myMethod:(myCompletion) compblock{
    //do stuff
    compblock(YES);
}

3)This is how you use it,

[self myMethod:^(BOOL finished) {
    if(finished){
        NSLog(@"success");
    }
}];

enter image description here

Leave a Comment