Re: C-Api Documentation - where?
Re: C-Api Documentation - where?
- Subject: Re: C-Api Documentation - where?
- From: "Gerriet M. Denkmann" <email@hidden>
- Date: Sun, 26 Feb 2012 12:16:28 +0700
On 25 Feb 2012, at 03:00, Conrad Shultz <email@hidden> wrote:
>
> On 2/24/12 8:31 AM, Gerriet M. Denkmann wrote:
>> This is a Cocoa app which uses NSRunloop etc. but which also wants to
>> know about kEventAppFrontSwitched. I just looked at
>> CarbonEventsCore.h and it says about GetEventParameter:
>> AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER and nothing about
>> deprecated or legacy.
>
> I don't know Carbon, but I'm guessing from the constant's name that you
> want to be informed when the active application has changed?
>
> If so, the following pure Cocoa works for me:
>
> - (void)frontAppChanged:(NSNotification *)note
> {
> NSLog(@"Changed application: %@", [note userInfo]);
> }
>
> - (void)applicationDidFinishLaunching:(NSNotification *)aNotification
> {
> [[[NSWorkspace sharedWorkspace] notificationCenter] addObserver:self
> selector:@selector(frontAppChanged:)
> name:NSWorkspaceDidActivateApplicationNotification
> object:nil];
> }
Thank you very much.
This works as well as watching Carbon events.
It requires less code.
It probably is less in danger of being deprecated any time soon.
So: it is a much better solution.
Kind regards,
Gerriet.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden