+3  A: 

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.

kperryua
How would you pre process the implementation file? I have also updated the question with the full code.
Joshua
I preprocessed it but it's just a load of code.
Joshua
The additional context you added is immediately helpful. References to the ivars must be within Objective-C method definitions, because the implicit self parameter is needed to access them.You obviously can't do that since you are implementing a Carbon callback function. However, if you make the userData parameter a pointer to your HotKeyController, you should be able to access them that way.
kperryua
How would I make the userData parameter point to my HotKeyController?
Joshua
InstallApplicationEventHandler(Note the 4th parameter. Not sure what the "pl" you're currently passing is.Then, in the callback you can cast userData to (HotKeyController *) and access its ivars.Make sure something is keeping the HotKeyController object alive so the callbacks don't get a dangling pointer.
kperryua
How would I cast userData to (HotKeyController *) and access its ivars?
Joshua
HotKeyController *controller = (HotKeyController *)userData;controller->window;This is basic C stuff.
kperryua
Where would I put that code?
Joshua
Where would I put that code exactly?
Joshua
Can you tell me where I put the code?
Joshua
*sigh*... Put it in MyHotKeyHandler. The first line goes somewhere before the switch statement. Replace any references to 'window' with controller->window, searchWindow with controller->searchWindow, and so forth.If the compiler complains about direct access of the ivars (not sure if it would in this case), you'll want to make accessor functions and call those instead.
kperryua
Thanks but What is the Switch Statement?
Joshua
Found out what the Switch Statement was so I put directly before it, but got multiple errors. Pic. http://snapplr.com/sjvw
Joshua
Also tried putting it in a different place, but still got errors. Pic. http://snapplr.com/xhr1
Joshua
Heh... this is ludicrous, but I'll play along, since I'm amused. You forgot a semicolon after the declaration. That should be obvious.
kperryua
+6  A: 

The error I get is Xcode saying 3 things are un-declared …

But in the Header File I have declared them …

Why I am getting these errors when I have declared them [in the HotKeyController class].

Because those lines are in a function, not in a method of the HotKeyController class. It doesn't matter where you put the function (inside @implementation or not); it's still a function, not a method.

How would I make the userData parameter point to my HotKeyController?

You set that when you create the event handler. In fact, you're already setting it to “pl”, whatever that is.

Peter Hosey
Ah, I see. The thing is I got the code from a tutorial. In fact "pl" is also un-declared. Do you know what I should change it to?
Joshua
You wanted to change it to the HotKeyController, remember?
Peter Hosey
So I change it to HotKeyController right?
Joshua
No, that's a class name. That would be a syntax error, and you don't want to pass the class anyway. You need to pass the HotKeyController object—the one you're installing the event handler from. (And if you don't know how to do that, you should re-read the Objective-C Programming Language: http://developer.apple.com/documentation/Cocoa/Conceptual/ObjectiveC/ in particular: http://developer.apple.com/documentation/Cocoa/Conceptual/ObjectiveC/Articles/ocDefiningClasses.html#//apple_ref/doc/uid/TP30001163-CH12-BAJHDGAC )
Peter Hosey
A: 

NSWindow is not defined in the Foundation framework, you must import the right headers, ApplicationKit or Cocoa.

Failing to import the AppKit header would not cause his instance variables to go missing. His problem is that he's trying to access them from a function.
Peter Hosey