I found interesting things.. Following code doesn’t show @”One” and it show @”Two” after 3 seconds delay..
I think that @”One” need to be shown and then 3 seconds delay and then @”Two” need to pop up..
Am I wrong?
self.statusLabel.text = @"One";
sleep(3);
self.statusLabel.text = @"Two";
Thanks..
If you’re doing this on the main thread, that
sleep(3)will block it, freezing the app for 3 seconds. Event processing, including things like repainting the UI, won’t happen til that’s over.To get what you’re expecting, try something like this:
Does the first change, then queues up an invocation performing the second change to happen in the future. Then returns control to the OS to do any necessary redrawing.