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?

from: https://developer.apple.com/library/ios/documentation/uikit/reference/uiview_class/uiview/uiview.html#//apple_ref/occ/clm/uiview/animatewithduration:animations:

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

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -