Re: post events to NSApplication
Re: post events to NSApplication
- Subject: Re: post events to NSApplication
- From: "Michael Ash" <email@hidden>
- Date: Wed, 6 Aug 2008 18:06:16 -0400
On Tue, Aug 5, 2008 at 10:18 PM, Jim Crafton <email@hidden> wrote:
> Is it possible to create a custom event for an apps internal usage and
> have it posted to the NSApp, and then processed later on? If so, how
> would one do this? I'm not sure how to
> a) create the event
> b) get notified when the event is recv'd and ready for processing
>
> The event loop is whatever is being run by calling [NSApp run].
Ken already answered your question, but I would propose that it is the
wrong question to ask. In my many years of writing code with Cocoa,
I've almost never had to do this.
("Almost" because there are two cases where it is useful: pinging an
event tracking runloop, and working around the Cocoa bug where
autorelease pools are only popped when an NSEvent is processed.)
Rather than use an event, it sounds like you just want to use a timer.
Create an NSTimer, set the time interval to whatever you need (0 if
you want it "as soon as possible), set the target and selector to
whatever it is you want to run, and that target/selector pair will be
invoked at the next opportunity.
Mike
_______________________________________________
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