• 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: Trouble with "self" in Carbon and Cocoa
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Trouble with "self" in Carbon and Cocoa


  • Subject: Re: Trouble with "self" in Carbon and Cocoa
  • From: Vince DeMarco <email@hidden>
  • Date: Mon, 24 Mar 2003 10:51:57 -0800

Since self is the application object change it to

OSStatis HotKeyHander(...)
{
[anObject aMethod];
[NSApp myCocoaMethod:YES];
}


On Saturday, March 22, 2003, at 2:23 AM, Jeffrey Mattox wrote:

I have a hotkey handler that needs to call a method using "self" but it causes a compile error. Elsewhere in my program I'm using "self" without error. The hotkey handler is a C routine because that's what I need in order to register it as the handler. Here's the outline:

#import <Cocoa/Cocoa.h>
#import <Carbon/Carbon.h>

@implementation NSApplication (mainline)

OSStatus HotKeyHandler(...)
{
[anObject aMethod]; // works for Foundation, et al
[self myCocoaMethod:YES]; // <--- causes "self" undeclared error
{

-(void) myCocoaMethod:(BOOL)flag
{
// never get here
}

@end

As a workaround, I can make it work by saving the value of "self" in another variable during initialization and use that later in my handler. E.g,:

NSApplication *mySelf;
...
{
...
mySelf = self;
}

I want to understand why the compiler is complaining. What must I to do to get "self" to work in HotKeyHandler()?

Jeff
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: Trouble with "self" in Carbon and Cocoa
      • From: Bill Cheeseman <email@hidden>
References: 
 >Trouble with "self" in Carbon and Cocoa (From: Jeffrey Mattox <email@hidden>)

  • Prev by Date: Screen location of cursor in NSTextView
  • Next by Date: Correct way to locate 'Application Support' folder?
  • Previous by thread: Re: Trouble with "self" in Carbon and Cocoa
  • Next by thread: Re: Trouble with "self" in Carbon and Cocoa
  • Index(es):
    • Date
    • Thread