Question

I'm trying to access the instance variables I've declared in my AppDelegate, but my class seams to think that my AppDelegate is an NSButton.

I borrowed this code from Referencing AppDelegate instance variables

AppDelegate *appDelegate = (AppDelegate *)[[NSApplication sharedApplication] delegate];
NSLog(@"appDelegate %@", appDelegate );

NSLog returns: appDelegate NSButton: 0x6000001553a0

Because appDelegate seems to be an NSButton, obviously it doesn't take well to my trying to ask it for variables, it gives me "unrecognized selector sent to instance."

I'm missing something important, why doesn't appDelegate point to my AppDelegate class?

Was it helpful?

Solution

It sounds like you hooked up the “File’s Owner”’s delegate outlet in MainMenu.xib to be a button accidentally. Instantiate your AppDelegate in the XIB and point the ‘delegate’ outlet to that, instead.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top