Where should I put code that is supposed to fire AFTER the view has loaded?

Posted by Timbo on Stack Overflow See other posts from Stack Overflow or by Timbo
Published on 2010-05-25T02:54:17Z Indexed on 2010/05/25 3:01 UTC
Read the original article Hit count: 291

Filed under:
|
|

I’m writing an objective-c program that does some calculations based on time and will eventually updates UILabels each second.

To explain the concept here’s some simplified code, which I’ve placed into the viewDidLoad of the class that handles the view.

  • (void)viewDidLoad {

    [super viewDidLoad]; // how do i make this stuff happen AFTER the view has loaded?? int a = 1; while (a < 10) { NSLog(@"doing something"); a = a + 1; sleep(1); }
    }

My problem is that the code halts the loading of the view until the loop is all complete (in this case 10 seconds).

Where should I put code that I want to fire AFTER the view has finished loading?

newbie question I know =/

© Stack Overflow or respective owner

Related posts about iphone

Related posts about objective-c