Sorry, forgot to hit Reply All..

On May 25, 2008, at 10:45 AM, Steve Steinitz wrote:

Hello,

This is hard to google for because they are such common words:

how do I delay, wait, pause for a tenth of a second?

I don't want to use NSTimer because I just want to resume where I left off. I don't want to be in a tight loop because I need the system to finish something. I just want to pause execution for a short time. I think there was a wait() in OS9. I found a wait() in wait.h but it wants an int * and made me nervous.

Specifically, when I send a fetch message to an NSArrayController, it sometimes takes a fraction of a second for its selection to become valid. Currently I fire an NSTimer to call a 'part 2' method to finish what I am doing (scrolling the selection into view), but it lacks niceness.

Thanks,

Steve


Have to agree with Thomas that delay is the wrong way to handle this. From 10.4 on fetch: results are delayed until the next iteration of the run loop so (please correct me if I'm wrong) the simplest solution would be to just manually iterate through the loop twice:

        ...
        [arrayController fetch:nil];
[[NSRunLoop mainRunLoop] runUntilDate:[NSDate distantPast]]; // finish current iteration [[NSRunLoop mainRunLoop] runUntilDate:[NSDate distantPast]]; // iterate one more time to allow selection to update
        NSUInteger selection = [arrayController selectionIndex];
        ...


- Dmitri
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to