views:

146

answers:

2

I think there is a minimum time span that we can assign as interval to schedule a task in iPhone SDK. But I haven't found that minimum interval/time span yet.

Would you let me know please! It will be very helpful to me.

EDIT

Any detail reference is more appreciative. Thanks in advance

+1  A: 

0.0 I believe. I've seen this used as a "trick" to get the system to run something immediately after the current thread goes into a wait state.

http://developer.apple.com/mac/library/documentation/Cocoa/Reference/Foundation/Classes/NSObject_Class/Reference/Reference.html#//apple_ref/occ/instm/NSObject/performSelector:withObject:afterDelay:

"The minimum time before which the message is sent. Specifying a delay of 0 does not necessarily cause the selector to be performed immediately. The selector is still queued on the thread’s run loop and performed as soon as possible."

The implication is, you can specify 0.

Steve
@Steve, frankly speaking- `0` interval is useless, since i can do it without scheduler. Is it means that i can specify something like 0.000000000001, which is greater than `0`?
Sadat
I wouldn't say 0 interval is useless. It's actually quite useful if you want something to run immediately after your thread enters sleep... for example, I use it in my ApplicationDidFinishLaunching method because I need the rest of the application initialization to finish (for example, to handle a url request), but still want to run the method the instant the thread is ready. Yes, you can specify any valid double precision floating point value >= 0.
Steve
Why not use one of the `performSelector` variants in that case?
Georg Fritzsche
That's what I referenced. Not sure I understand the comment.
Steve
+2  A: 

NSTimeInterval is just a "double", so can specify any double value. The smallest value next to 0 is about 2.225e-308.

However, remember that NSTimer is not a high-precision tool. You can specify very small intervals, but they aren't honored by the OS. Here's what the documentation for NSTimer says:

the effective resolution of the time interval for a timer is limited to on the order of 50-100 milliseconds

nschum