objective c - Method body for a generic Obj-C method with a completion block -


i love using animatewithduration:options:completion. have come across few situations use own scenario without animation, having difficulty writing method body out. can't @ uiview's code, it's signatures.

here attempt (i may have method signatures messed too):

.h +(void)performgenericblock:(void(^)(bool))code actionwhendone:(void(^)(void))action;  .m +(void)performgenericblock:(void(^)(bool))code actionwhendone:(void(^)(void))action {    //kind of lost here - here psuedocode    [do stuff:^(bool done){action}]; } 

basically want accomplish:

perform first block of code, when done, second block of code.

not sure why need 2 arguments, should able write code in original block.

in following examples, assume want first call [self.test foo1] [self.test foo2].

the simplest solution not create new method @ all. call code:

[self.test foo1]; [self.test foo2]; 

foo2 performed after foo1.

the second simplest solution create function 1 argument:

[viewcontroller performgenericblock:^{     [self.test foo1];     [self.test foo2]; }]; 

if need 2 arguments, following:

[viewcontroller performgenericblock:^{     [self.test foo1]; } actionwhendone:^{     [self.test foo2]; }]; 

... , define method so:

+ (void)performgenericblock:(void(^)(void))code actionwhendone:(void(^)(void))action {     code();     action(); } 

Comments

Popular posts from this blog

user interface - How to replace the Python logo in a Tkinter-based Python GUI app? -

objective c - Greedy NSProgressIndicator Allocation -

how to set an OCR language in Google Drive -