On Aug 24, 2018, at 2:21 PM, James Walker <jam...@frameforge3d.com> wrote:
> What could cause a delayed perform (using -[NSObject performSelector: 
> withObject: afterDelay:]) to never happen?

I'm sure you've checked, but *just in case*, I'll ask: are you sure you're not 
sending it to nil?

> I wondered if I needed to do the delayed perform in a particular run loop 
> mode, and found that [[NSRunLoop currentRunLoop] currentMode] is nil, which 
> seems odd.  Why would the run loop not be running?

Where are you checking currentMode?  I did a quick test and noticed currentMode 
is nil in my app delegate's applicationDidFinishLaunching: method (I guess 
because the run loop hasn't started yet?), but it's non-nil a little later when 
my delayed perform is called.

My delayed perform "works for me", so I'm afraid I don't have much to suggest 
regarding that.

- (void)fire:(id)arg {
        NSLog(@"FIRED -- current run loop mode: %@",
                  [[NSRunLoop currentRunLoop] currentMode]);
        NSLog(@"%@", @"You're fired!");
}

- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
        NSLog(@"Did launch -- current run loop mode: %@",
                  [[NSRunLoop currentRunLoop] currentMode]);
        [self performSelector:@selector(fire:)
                           withObject:nil
                           afterDelay:0.175];
}

Output:

2018-08-24 17:34:18.852033-0400 Scratchy[94529:13604294] Did launch -- current 
run loop mode: (null)
2018-08-24 17:34:19.035517-0400 Scratchy[94529:13604294] FIRED -- current run 
loop mode: kCFRunLoopDefaultMode
2018-08-24 17:34:19.038105-0400 Scratchy[94529:13604294] You're fired!

--Andy

_______________________________________________

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to