I want to start an activity indicator before going to disk I/O.
How do I start the indicator NOW, instead of waiting for the next display loop cycle? Or how do I force the display loop before beginning the disk I/O?
Dan
I want to start an activity indicator before going to disk I/O.
How do I start the indicator NOW, instead of waiting for the next display loop cycle? Or how do I force the display loop before beginning the disk I/O?
Dan
You can't force the indicator to start now as far as I'm aware. To push a method call so that it's the next thing in the runloop, you can use:
[self performSelector:@selector(taskToDo) withObject:nil afterDelay:0]
Which will schedule 'taskToDo' (optionally with a single argument) onto the current runloop, to occur as soon as it can. Then just let that segment of code exit. An equivalent method is to schedule an NSTimer, but syntactically that's a bit more lengthy.
If I understand correctly your IO operation takes some time, and you want the UI to update as you're performing it, right? If that's the case, you have to move your operation to a background thread for the UI to have a chance to update itself, there's no workaround. use performSelectorInBackground:withObject:
to call your IO operation, use NSOperation
, or blocks if you're targeting iOS 4.0+