How to execute statements in order in objective c

Posted by Vu Tu?n Anh on Stack Overflow See other posts from Stack Overflow or by Vu Tu?n Anh
Published on 2013-10-29T15:45:22Z Indexed on 2013/10/29 15:53 UTC
Read the original article Hit count: 277

Filed under:
|

When i tap on my button, my function was called

[myBtn addTarget:self action:@selector(myFunction) forControlEvents:UIControlEventTouchUpInside];

In my function, a collection of complex statement will be executed and take a litte bit time to run, so i want to show Loading (UIActivityIndicatorView) as the following:

-(void) addTradeAction {
    //Show Loading
    [SharedAppDelegate showLoading];

    //disable user interaction
    self.view.userInteractionEnabled = NO;

    //execute call webservice in here - may be take 10s
    //Hide Loading
    [ShareAppDelegate hideLoading];
}

When tap on myBtn (my Button) -> after 3s or 4s, [ShareAppDelegate showLoading] was called.

It is unusual when i use [ShareAppDelegate showLoading] on other Function, -> it work very nice, i mean all the statement be executed in order.

All i want, when i tap on My Button, Loading will be called immediatelly.

Tks in advance

© Stack Overflow or respective owner

Related posts about ios

Related posts about objective-c