I have a UIViewController and a Category to add methods to a UIViewController. There is a method in the category:
@implementation UIViewController (AlertAnimationsAndModalViews) -(void)someAddedMethod { UIView *someView;
And in any controller view, I can call this method
[self someAddedMethod]
However, I want this method to run one at a time. For example, if I make two calls one by one
[self someAddedMethod];//call1 [self someAddedMethod];//call2
I want the second call to wait for the completion of the first call. I understand that the animation of UIViewWithduration ... is executed in a separate thread, and, seeing that I cannot create iVars in category i, I cannot use @synchronized (someObject) ..
Any tips?
Thanks in advance!
EDIT
The method is as follows:
-(void)showTopBannerWithHeight:(CGFloat)height andWidth:(CGFloat)width andMessage:(NSString *)message andDuration:(CGFloat)duration { UILabel *messageLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, -height, width, height)]; [self.view.superview addSubview:messageLabel]; [UIView animateWithDuration:0.5 delay:0 options: UIViewAnimationOptionBeginFromCurrentState animations:^{ messageLabel.frame = CGRectMake(0, 0, SCREEN_WIDTH, height); } completion:^(BOOL finished){ [UIView animateWithDuration: 0.5 delay:duration options: UIViewAnimationOptionBeginFromCurrentState animations:^{ messageLabel.frame = CGRectMake(0, -height, SCREEN_WIDTH, height); } completion:^(BOOL finished){ [messageLabel removeFromSuperview]; }]; }];
}
So, I show the βbannerβ at the top of the screen, wait for the duration (CGFloat), then shift the view from the screen and delete it. Since this is in a category, I cannot add instance variables. therefore, I want to ensure that if more than one call to this method is made, I want the first call to be made without waiting, but each call after this should wait until the previous call ends.