A O
A O

Reputation: 5698

Can't figure out "Unrecognized selector sent to instance" source

So I am at my wit's end on this, I am toggling some sharedprefs back and forth, and eventually it makes my app crash. I thought it was because I wasn't deallocating observers properly, but upon looking at the crash log it says that an unrecognized selector is sent to instance. Does anybody know more about crash logs that can tell me more about what's happening? I can get the basic gist of what's happening out of the log, but I'm still a rookie and a lot of the information is going over my head.

Crashed Thread:  0  Dispatch queue: com.apple.main-thread

Exception Type:  EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000

Application Specific Information:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFType _adjustLengthDueToViewFrameChange:]: unrecognized selector sent to instance 0x608000095b80'
terminating with uncaught exception of type NSException
abort() called

Application Specific Backtrace 1:
0   CoreFoundation                      0x00007fff8fdcb25c __exceptionPreprocess + 172
1   libobjc.A.dylib                     0x00007fff92afae75 objc_exception_throw + 43
2   CoreFoundation                      0x00007fff8fdce12d -[NSObject(NSObject) doesNotRecognizeSelector:] + 205
3   CoreFoundation                      0x00007fff8fd29272 ___forwarding___ + 1010
4   CoreFoundation                      0x00007fff8fd28df8 _CF_forwarding_prep_0 + 120
5   CoreFoundation                      0x00007fff8fd99e0c __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 12
6   CoreFoundation                      0x00007fff8fc8d82d _CFXNotificationPost + 2893
7   AppKit                              0x00007fff915a4003 -[NSView _postFrameChangeNotification] + 434
8   AppKit                              0x00007fff915ad6c2 -[NSView setFrameSize:] + 1586
9   AppKit                              0x00007fff915ad049 -[NSView setFrame:] + 294
10  AppKit                              0x00007fff915acc2b -[NSWindow setContentView:] + 453
11  AppKit                              0x00007fff91beeace -[NSStatusItem setView:] + 224
12  MyAppHelper                        0x00000001000775f5 -[NSStatusItem(BCStatusItem) setupView] + 85
13  MyAppHelper                        0x000000010000cdbb -[MyAppHelperCapHelperServer createStatusBarItem] + 299
14  MyAppHelper                        0x000000010000cf5b -[MyAppHelperCapHelperServer insertCaptureMenu] + 43
15  MyAppHelper                        0x000000010000fe3d -[MyAppHelperHelperServer observeValueForKeyPath:ofObject:change:context:] + 733
16  Foundation                          0x00007fff927e8f28 NSKeyValueNotifyObserver + 387
17  Foundation                          0x00007fff927e80f8 NSKeyValueDidChange + 453
18  Foundation                          0x00007fff927ecbe6 -[NSObject(NSKeyValueObserverNotification) didChangeValueForKey:] + 118
19  MyAppHelperHelper                        0x0000000100109a3d __57-[RMSharedUserDefaults __applyBaselineAndNotify:updates:]_block_invoke + 349
20  CoreFoundation                      0x00007fff8fd086df __65-[__NSDictionaryM enumerateKeysAndObjectsWithOptions:usingBlock:]_block_invoke + 111
21  CoreFoundation                      0x00007fff8fd085ee -[__NSDictionaryM enumerateKeysAndObjectsWithOptions:usingBlock:] + 222

Primarily, I have no idea what it means in the exception information: [__NSCFType _adjustLengthDueToViewFrameChange:]. I cannot seem to find any information anywhere.

Thanks in advance!

Upvotes: 0

Views: 526

Answers (1)

Paul N
Paul N

Reputation: 1931

First, I assume you are manually managing the memory, if so, I'll Highly recommend you to migrate to ARC (Automatic Reference Counting) it will manage the memory for you and you wont have this type or errors anymore. There are plenty of tutorials on Google of how to do this. You can read more here: Transitioning to ARC Release Notes

Second, without ARC, this kind of error is often caused because you are calling a method/selector on an already released object, that's why the method/selector is not recognized.

This assuming you take care of clearing all the warnings on your project, if not, first go and check if there isn't a warning already pointing that you are trying to call a method/selector that doesn't exist for some object in your app. You can use the Analyze option as mentioned on the comments of this answer. To do that just Cmd+Shift+b, select the Analyze option from the Product Menu or Press and Hold the "Play" button you use to build the app and you will see the Analyze option as well.

Finally, I see you are using User Defaults. I'll recommend making sure you are retaining the values you are receiving from the User Defaults as they came with autorelease. This will explain why the compiler is not able to show the exact line of code where this error is happening, because it happens until the objet is autoreleased.

If is not the User Defaults I'll go and check all my autoreleased variables, is most likely that the problem is with one of them.

Upvotes: 2

Related Questions