The method accepts up to two callbacks, animations
and complete
. If I define what needs to be done in class methods, how to pass them to animateWithDuration
?
the signature looks like
+ (void)animateWithDuration:(NSTimeInterval)duration animations:(void (^)(void))animations
Usually it looks something 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 what I am looking for is assigning animations
to some method in my class.
This method is chosen as an well-known example. However the root is that I have my own class that tries to do the same approach and I was wondering if I could keep code cleaner by not calling class methods within callbacks.
The biggest thing that I don't like is NSError **
parameter I am using for my callback that is called in case of errors. Subcalls will require some sort of global variable and I really don't like that. So here is my signature for completeness:
- (void)registerWithEmail:(NSString *)email
name:(NSString *)name
willRegister:(void (^)(void))willRegister
didRegister:(void (^)(void))didRegister
registerError:(void (^)(NSError**))registerError;