0
votes

Cocoa/Objective-C newbie here.

I have a MainMenu.xib file which has a NSView. This is what awakeFromNib in AppDelegate.h looks like :

- (void)awakeFromNib {
NSViewController *x = [[Login alloc] initWithNibName:@"Login" bundle:nil];
NSView *v = [x view];
[_theView addSubview:v];    

}

The new view has a button but when I click on it, I get the message "unrecognized selector sent to instance".

I'm completely lost. Please help me with this. Thanks!

It also throws as "Thread 1: EXC_BAD_ACCESS (code = 1, address = ...) at the line (in main.m):

return NSApplicationMain(argc, argv);

The error is :

2014-10-14 09:05:09.743 FAST Tax Scanner[18408:303] -[OS_dispatch_queue_runloop login:]: unrecognized selector sent to instance 0x6000000f7900 2014-10-14 09:05:09.743 FAST Tax Scanner[18408:303] -[OS_dispatch_queue_runloop login:]: unrecognized selector sent to instance 0x6000000f7900 2014-10-14 09:05:09.744 FAST Tax Scanner[18408:303] ( 0 CoreFoundation 0x00007fff9484725c exceptionPreprocess + 172 1 libobjc.A.dylib 0x00007fff8c72fe75 objc_exception_throw + 43 2 CoreFoundation 0x00007fff9484a12d -[NSObject(NSObject) doesNotRecognizeSelector:] + 205 3 CoreFoundation 0x00007fff947a5272 ___forwarding_ + 1010 4 CoreFoundation 0x00007fff947a4df8 _CF_forwarding_prep_0 + 120 5 AppKit 0x00007fff8b87d260 -[NSApplication sendAction:to:from:] + 327 6 AppKit 0x00007fff8b87d0de -[NSControl sendAction:to:] + 86 7 AppKit 0x00007fff8b8c9c4d -[NSCell _sendActionFrom:] + 128 8 AppKit 0x00007fff8b8e3655 -[NSCell trackMouse:inRect:ofView:untilMouseUp:] + 2316 9 AppKit 0x00007fff8b8e2a27 -[NSButtonCell trackMouse:inRect:ofView:untilMouseUp:] + 487 10 AppKit 0x00007fff8b8e213d -[NSControl mouseDown:] + 706 11 AppKit 0x00007fff8b863a58 -[NSWindow sendEvent:] + 11296 12 AppKit 0x00007fff8b8025d4 -[NSApplication sendEvent:] + 2021 13 AppKit 0x00007fff8b6529f9 -[NSApplication run] + 646 14 AppKit 0x00007fff8b63d783 NSApplicationMain + 940 15 FAST Tax Scanner 0x0000000100001452 main + 34 16 libdyld.dylib 0x00007fff982c55fd start + 1 17 ??? 0x0000000000000003 0x0 + 3 )

1
Paste in the complete error message so we can see which selector and which instance it's complaining about. Also, if the error happens on a button click you might want to show the code that executes in response to that button action.Phillip Mills
this can also happen if you wire up things wrong in xcodemeda
@PhillipMills done. Thanks for your time!AyushISM
It says that you're calling a login: method on an object that doesn't recognize that method. Since it's not the type of object you would normally be using, I suspect you're trying to use something that has been released. What does the code look like where you're using a login: call? (Or perhaps you've connected your control to a login: method of something that doesn't exist at the time it runs.)Phillip Mills

1 Answers

1
votes

Oh, I see....

Try saving NSViewController *x as a strong property of the object that creates it instead of having it as a local variable. The way it's currently created, the Login object will not survive past the end of the awakeFromNib method.