开发者

any library function that provides the function of wait in objective c

HI I want to use a function that do the work as of wait() in obj.C .(not NSTimer coz i dont want to call any function all that i want is to wait for a few seconds and then display images after 开发者_运维知识库each other.


Use performSelector:withObject:afterDelay: ! wait() will freeze your app !!!


wait() is a function. If you don't want to call a function then you can't achieve what you want, or indeed pretty much anything else. But I guess you mean that you don't want an actor that ends up calling a method on your class — you want a direct, inline pause? Then, you probably want:

[NSThread sleepForTimeInterval:timeInSeconds]; // e.g. 2.0 to sleep 2 seconds

EDIT: though, ideologically, I completely agree with Benoît. A perfect program shouldn't allow the UI thread to block at any point.


The key here is "display images". If you try to draw an image, suspend the main thread (ack!) and then try to draw another one, you won't see the images anyway.

So you'll need to use an NSTimer or performSelector:...Delay:

These techniques allow your app's main thread to return to the run loop which is necessary to do any drawing at all.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜