The error I get is Xcode saying 3 things are un-declared (see below picture) alt text http://snapplr.com/snap/ks4h
But in the Header File I have declared them (see below picture)
alt text http://snapplr.com/snap/htmb
Why I am getting these errors when I have declared them.
The Full Code:
Header File.
#import <Foundation/Foundation.h>
@interface HotKeyController : NSObject {
IBOutlet NSButton *cmdHK;
IBOutlet NSButton *ctrHK;
IBOutlet NSButton *optHK;
IBOutlet NSPopUpButton *keyHK;
IBOutlet NSWindow *window;
IBOutlet NSWindow *searchWindow;
IBOutlet NSWindow *entryWindow;
}
@end
Implementation File
#import "HotKeyController.h"
#include <Carbon/Carbon.h>
@implementation HotKeyController
OSStatus MyHotKeyHandler(EventHandlerCallRef nextHandler,EventRef theEvent,void *userData)
{
EventHotKeyID hkCom;
GetEventParameter(theEvent,kEventParamDirectObject,typeEventHotKeyID,NULL,sizeof(hkCom),NULL,&hkCom);
int l = hkCom.id;
switch (l) {
case 1: [window makeKeyAndOrderFront:NSApp];
break;
case 2: [searchWindow makeKeyAndOrderFront:nil];
break;
case 3: [entryWindow makeKeyAndOrderFront:nil];
break;
}
return noErr;
}
- (void)awakeFromNib
{
//Register the Hotkeys
EventHotKeyRef gMyHotKeyRef;
EventHotKeyID gMyHotKeyID;
EventTypeSpec eventType;
eventType.eventClass=kEventClassKeyboard;
eventType.eventKind=kEventHotKeyPressed;
InstallApplicationEventHandler(&MyHotKeyHandler,1,&eventType,pl,NULL);
gMyHotKeyID.signature='htk1';
gMyHotKeyID.id=1;
if([[NSUserDefaults standardUserDefaults] integerForKey:@"hotkeyShowMain"]!=-999) {
RegisterEventHotKey([[NSUserDefaults standardUserDefaults] integerForKey:@"hotkeyShowMain"], [[NSUserDefaults standardUserDefaults] integerForKey:@"hotkeyShowMainModifier"], gMyHotKeyID, GetApplicationEventTarget(), 0, &gMyHotKeyRef);
}
gMyHotKeyID.signature='htk2';
gMyHotKeyID.id=2;
if([[NSUserDefaults standardUserDefaults] integerForKey:@"hotkeyShowSearch"]!=-999) {
RegisterEventHotKey([[NSUserDefaults standardUserDefaults] integerForKey:@"hotkeyShowSearch"], [[NSUserDefaults standardUserDefaults] integerForKey:@"hotkeyShowSearchModifier"], gMyHotKeyID, GetApplicationEventTarget(), 0, &gMyHotKeyRef);
}
gMyHotKeyID.signature='htk3';
gMyHotKeyID.id=3;
if([[NSUserDefaults standardUserDefaults] integerForKey:@"hotkeyShowEntry"]!=-999) {
RegisterEventHotKey([[NSUserDefaults standardUserDefaults] integerForKey:@"hotkeyShowEntry"], [[NSUserDefaults standardUserDefaults] integerForKey:@"hotkeyShowEntryModifiers"], gMyHotKeyID, GetApplicationEventTarget(), 0, &gMyHotKeyRef);
}
}
@end
You would have to show more of the file to be sure. Are you properly importing the header file? Have you saved the header file?
Try inserting the explicit self-> references and you might get a more revealing error message.
Also, try preprocessing the implementation file (in the Build menu) and that might reveal why the ivar isn't being found.