0
votes

Please let me tell you what I am doing.

  1. I have a window that has a NSView "MainContainer"
  2. On laod of the window I am adding a custom view "Options" in the NSView of the window
  3. There is a button on the customer view "Options" named "Customer Details"

On Customer Details click>> current view(Options) gets removed and a new view (customer details view) gets loaded. How I am doing is given below:

NSViewController* cdv = [[CustomerDetailsView alloc] init];
NSView* MainView = [[self view] superview];
[[self view] removeFromSuperview];
[MainView  addSubview:[cdv view]];

Now the issue is that the last view (Customer Detail View) has some buttons and no one is working and I am getting an error which is "unrecognized selector sent to instance". Please let me know what should I do? enter image description here enter image description here

2015-09-17 15:45:37.872 TechHeal[5058:125394] not start
2015-09-17 15:46:05.452 TechHeal[5058:125394] -[NSSnapshotContextSignature encryptClick:]: unrecognized selector sent to instance 0x6080000e5c80
2015-09-17 15:46:05.452 TechHeal[5058:125394] -[NSSnapshotContextSignature encryptClick:]: unrecognized selector sent to instance 0x6080000e5c80
2015-09-17 15:46:05.464 TechHeal[5058:125394] (
    0   CoreFoundation                      0x00007fff9834a03c __exceptionPreprocess + 172
    1   libobjc.A.dylib                     0x00007fff8e54c76e objc_exception_throw + 43
    2   CoreFoundation                      0x00007fff9834d0ad -[NSObject(NSObject) doesNotRecognizeSelector:] + 205
    3   CoreFoundation                      0x00007fff98292e24 ___forwarding___ + 1028
    4   CoreFoundation                      0x00007fff98292998 _CF_forwarding_prep_0 + 120
    5   libsystem_trace.dylib               0x00007fff95ef2cd7 _os_activity_initiate + 75
    6   AppKit                              0x00007fff9127eeb1 -[NSApplication sendAction:to:from:] + 452
    7   AppKit                              0x00007fff91294946 -[NSControl sendAction:to:] + 86
    8   AppKit                              0x00007fff91294862 __26-[NSCell _sendActionFrom:]_block_invoke + 131
    9   libsystem_trace.dylib               0x00007fff95ef2cd7 _os_activity_initiate + 75
    10  AppKit                              0x00007fff912947bf -[NSCell _sendActionFrom:] + 144
    11  libsystem_trace.dylib               0x00007fff95ef2cd7 _os_activity_initiate + 75
    12  AppKit                              0x00007fff91292cb3 -[NSCell trackMouse:inRect:ofView:untilMouseUp:] + 2821
    13  AppKit                              0x00007fff912eb34f -[NSButtonCell trackMouse:inRect:ofView:untilMouseUp:] + 770
    14  AppKit                              0x00007fff91291366 -[NSControl mouseDown:] + 714
    15  AppKit                              0x00007fff917fb2dc -[NSWindow _reallySendEvent:isDelayedEvent:] + 14125
    16  AppKit                              0x00007fff9118ac86 -[NSWindow sendEvent:] + 470
    17  AppKit                              0x00007fff91187212 -[NSApplication sendEvent:] + 2504
    18  AppKit                              0x00007fff910b0b68 -[NSApplication run] + 711
    19  AppKit                              0x00007fff9102d244 NSApplicationMain + 1832
    20  TechHeal                            0x00000001000048e2 main + 34
    21  TechHeal                            0x0000000100001224 start + 52
    22  ???                                 0x0000000000000003 0x0 + 3
)
(lldb) 

PS: If I am loading the Customer details directly then its working fine however if I am loading it from another view then its not working.

1
Post the complete exception text. It's important to know what the message is and what object it's being sent to.trojanfoe
surprising the error has been changed to unlock focus... I have added a screenshot. @trojanfoeVikas Bansal
That's a different error and therefore irrelevant.trojanfoe
@trojanfoe i have add the error log and screen shot. Please have a look.Vikas Bansal
OK so show the code that calls encryptClick:.trojanfoe

1 Answers

1
votes

You appear to be creating a CustomerDetailsView controller, taking its view, and then letting the controller go out of scope. Assuming encryptClick is implemented in that controller, the problem is that when it's called the object has already been released. The message is being passed to whatever now occupies that chunk of memory.

Try making cdv a strong property of whatever self is in your posted code so that it stays around to handle events.