views:

856

answers:

3

Is there an easy way to achieve that?

I have an UIImageView that reacts on a touch event. When the touch is detected, some animations happen in the App. After one second I want to call another method. In this case, I can't use the animationDidStop selector.

A: 

There are certainly several ways to do that, one of them might be to simply use sleep() to suspend the program/thread for a number of milliseconds, however I think you might want to tell us what exactly you're trying to accomplish by doing that? I mean, what is your actual problem? The idea of delaying a method call seems like a 'solution' to be, one that doesn't sound too good to be honest.

So, just tell us more about the scenario you have in mind.

none
wow, I was downvoted 4 times for response, nobody seems to realize that the original question was VERY vague!!
none
A: 

Make a call to sleep/wait/halt for 1000 ms just before calling your method?


Sleep(1000); // does nothing the next 1000 mSek

Methodcall(params); // now do the real thing


Tom Arleth
that would stop just everything in the app, right?
Thanks
Only in the current thread, other threads will continue to run.
Marc Charbonneau
+14  A: 

performSelector:withObject:afterDelay

Jim
This is the correct answer. Please see http://developer.apple.com/DOCUMENTATION/Cocoa/Reference/Foundation/Classes/NSObject_Class/Reference/Reference.html#//apple_ref/occ/instm/NSObject/performSelector:withObject:afterDelay:
harms
Perfect answer! Works perfectly.
Thanks
that's what you can get by providing a carefully phrased question in the first place :-)
none