I have only included the code relevant to this label within the program.
In my viewDidLoad method I have
[startLabel setHidden:NO];
startLabel.text = @"Touch to Begin";
In the touchesBegan method I then have
startLabel.text = @"Loading . .";
[self fillArrays];
Then in the fill Arrays method I fill the arrays and then hide the label –
self.myArray = [NSArray arrayWithObjects:
[UIImage imageNamed:@"Frame 1.png"], . .etc etc etc . . . nil]];
[startLabel setHidden:YES];
However, the text is not updated before the Array is loaded. Resulting in the “Loading . . ” text never appearing. As it seems to be implemented after the Array is filled.
At the same time the setHidden bool is set to YES, thus one never sees the label.
I wish for the startLabel to update before the method begins to fill the Array as this takes some time. i.e. for the method to Operate sequentially.
Is this possible?
Thank You
You need to load the arrays on a different thread to that of your GUI updates.
See this article: http://evilrockhopper.com/2010/01/iphone-development-keeping-the-ui-responsive-and-a-background-thread-pattern/
The function you want is performSelectorInBackground
That way your UI updates and your Background work can be done at the same time.
You can run another function which updates the label on the main thread as well in a similar way:
performSelectorOnMainThreadThat way you load arrays in the background, and you update your UI on the main thread (which is good because I Think the UIKit is not thread safe.