문제

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?

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top