jylee jylee - 2 years ago 161
Objective-C Question

How to Wait in Objective-C

I want to change my

's text after 2 seconds.

I tried setting my
's text to "A text", and use
and finally changing the text to "Another text".

only freezes the app and "Another text" is set without displaying "A text" for 2 seconds.

How may I display "A text" for 2 seconds and then show "Another text"?

Answer Source

You can use

[self performSelector:@selector(changeText:) withObject:text afterDelay:2.0];

or if you want to display it periodically, check the NSTimer class.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download