I’m new developer in the beginning stages of writing a simple dictionary app for personal use on the iPhone, and I’m wondering what method to use to control how long my words are displayed on screen.
I’ve experimented with NSTimer and performSelector:withObject:afterDelay: but Im wondering if these are the simplest, most efficient ways to approach the problem.
I’m not sure if I should use a sleep method like NSThread sleepForTimeInterval: because I’d like to have the option to have other things going on in the app while the word list is on screen.
Any pointers?
A million thanks.
NSTimerorperformSelector:withObject:afterDelay:are both good options. TheperformSelector:withObject:afterDelay:seems more straight forward to use, in my opinion.You don’t want to use sleep, especially on the main thread. This will make your app unresponsive.
You might also want to look at block animations. You could, for example, fade the word on then off. See:
[UIView animateWithDuration:delay:options:animations:completion:]. It is a little more intimidating at first, especially if you are not familiar with code blocks. But this method gives you lots of control.