• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Delayed perform never performing
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Delayed perform never performing


  • Subject: Re: Delayed perform never performing
  • From: Andy Lee <email@hidden>
  • Date: Fri, 24 Aug 2018 17:36:41 -0400

On Aug 24, 2018, at 2:21 PM, James Walker <email@hidden> 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 (email@hidden)

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:

This email sent to email@hidden

References: 
 >Delayed perform never performing (From: James Walker <email@hidden>)

  • Prev by Date: Re: Delayed perform never performing
  • Next by Date: Bothersome "NSView-Encapsulated-Layout-Height" constraint?
  • Previous by thread: Re: Delayed perform never performing
  • Next by thread: Bothersome "NSView-Encapsulated-Layout-Height" constraint?
  • Index(es):
    • Date
    • Thread