ios - Is it possible to pass existing methods to callbacks defined similar to UIView.animateWithDuration? -
the method accepts 2 callbacks, animations
, complete
. if define needs done in class methods, how pass them animatewithduration
?
the signature looks
+ (void)animatewithduration:(nstimeinterval)duration animations:(void (^)(void))animations
usually looks like:
[uiview animatewithduration:0.2f delay:0.0f options:uiviewanimationoptioncurveeasein animations:^{ _someview.frame = cgrectmake(-150, -200, 460, 650); _someview.alpha = 0.0; } completion:^(bool finished) { }];
so looking assigning animations
method in class.
this method chosen well-known example. root have own class tries same approach , wondering if keep code cleaner not calling class methods within callbacks.
the biggest thing don't nserror **
parameter using callback called in case of errors. subcalls require sort of global variable , don't that. here signature completeness:
- (void)registerwithemail:(nsstring *)email name:(nsstring *)name willregister:(void (^)(void))willregister didregister:(void (^)(void))didregister registererror:(void (^)(nserror**))registererror;
just call method within block.
[uiview animatewithduration:0.4 animations:^{ [self yourmethod]; //...or [yourclass yourmethod]; // said 'class' methods } completion:^(bool finished) { [self yourcompletion]; }];
Comments
Post a Comment