How to make sure an action completes before you continue

Posted by HurkNburkS on Stack Overflow See other posts from Stack Overflow or by HurkNburkS
Published on 2013-11-09T03:49:01Z Indexed on 2013/11/09 3:53 UTC
Read the original article Hit count: 128

Filed under:
|
|

I am trying to close a UIView thats in one method from another method by calling it, The UIView closes fine but not untill after all of the processes are finished in the current method.

I would like to know if there is a way to force the first thing to happen first (i.e. close UIviews) then continue the current method?

This is what my method looks like

- (void)selectDeselectAllPressed:(UIButton*)button {
    int id = button.tag;
    [SVProgressHUD showWithStatus:@"Updating" maskType:SVProgressHUDMaskTypeGradient];
    [self displaySelected]; // removes current view so you can load hud will not be behind it

    if (id == 1) {
        [self selectAllD];
    } else if (id == 2) {
        [self deselectAllD];
    } else if (id == 3) {
        [self selectAllI];
    } else if (id == 4) {
        [self deselectAllI];
    }
}

as you can see what happens is this method is called when a button is pressed, I would like for the displaySelected method to do what it needs to do before any of the other methods are called?

Currently what happes when i debug this is displaySelected method is called the thread walks through that then continues to the if statment then after the method in the if statment has finished then displaySelected changes are made... its so weird.

any help would be greatly appreciated.

© Stack Overflow or respective owner

Related posts about ios

Related posts about objective-c