__NSCFNumber unrecognized selector sent to instance - Weird behavior - ios

I'm having a really strange problem with an object of my class, inside a block a have a weak reference of my View Controller, part of the code in the block is
__weak typeof(self) weakSelf = self;
[weakSelf performSelector:#selector(reloadItems) withObject:nil afterDelay:0];
[weakSelf.view setUserInteractionEnabled:YES];
if (weakSelf.shouldPresentNotification) {
[[LLAPI sharedInstance] presentLatestNotification];
weakSelf.shouldPresentNotification = NO;
}
The problem is that probably a couple of my users have experienced this crash
[__NSCFNumber shouldPresentNotification]: unrecognized selector sent to instance 0xbb3c1937855f68da
Now, I understand that the crash report is telling me that weakSelf is an NSNumber object, but that doesn't really make any sense, and if that is true why would the crash be raised only until the variable "shouldPresentNotification" is accessed?
EDIT:
Here is the full stack trace:
Thread : Fatal Exception: NSInvalidArgumentException
0 CoreFoundation 0x0000000182154f5c __exceptionPreprocess
1 libobjc.A.dylib 0x0000000196d4bf80 objc_exception_throw
2 CoreFoundation 0x000000018215bc6c
__methodDescriptionForSelector
3 CoreFoundation 0x0000000182158c14 ___forwarding___
4 CoreFoundation 0x000000018205cdcc _CF_forwarding_prep_0
5 Laclud 0x00000001001109c4 __38-[LLMainVC processLacludSession]_block_invoke424 (LLMainVC.m:467)
6 Laclud 0x000000010011055c -[LLMainVC processLacludSession] (LLMainVC.m:516)
7 Laclud 0x000000010013ff30 __32-[LLGFVC sendFeedback]_block_invoke (LLGiveFeedbackVC.m:137)
8 Laclud 0x000000010014a40c __41-[LLAPI rateLonJet:like:success:failure:]_block_invoke (LLAPI.m:189)
9 Laclud 0x000000010034349c __66-[RKObjectRequestOperation setCompletionBlockWithSuccess:failure:]_block_invoke236 (RKObjectRequestOperation.m:481)
10 libdispatch.dylib 0x00000001975457b0 _dispatch_call_block_and_release
11 libdispatch.dylib 0x0000000197545770 _dispatch_client_callout
12 libdispatch.dylib 0x000000019754ae20 _dispatch_main_queue_callback_4CF
13 CoreFoundation 0x000000018210c258 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__
14 CoreFoundation 0x000000018210a0c0 __CFRunLoopRun
15 CoreFoundation 0x0000000182038dc0 CFRunLoopRunSpecific
16 GraphicsServices 0x000000018d18c088 GSEventRunModal
17 UIKit 0x0000000187712f44 UIApplicationMain
18 Laclud 0x0000000100178900 main (main.m:15)
19 libdyld.dylib 0x00000001975768b8 start
Any help appreciated.
Thanks

Related

-[_NSObserverList setCursorPosition:]

I am getting #560 NSInvalidArgumentException error as shown below;
-[_NSObserverList setCursorPosition:]: unrecognized selector sent to instance 0x1702a6ea0
CoreFoundation ___exceptionPreprocess
Fatal Exception: NSInvalidArgumentException
0 CoreFoundation 0x1854f21c0 __exceptionPreprocess
1 libobjc.A.dylib 0x183f2c55c objc_exception_throw
2 CoreFoundation 0x1854f9278 __methodDescriptionForSelector
3 CoreFoundation 0x1854f6278 ___forwarding___
4 CoreFoundation 0x1853f059c _CF_forwarding_prep_0
5 UIKit 0x18b830418 -[_UIKeyboardTextSelectionController selectTextWithGranularity:atPoint:executionContext:]
6 UIKit 0x18b8304b0 -[_UIKeyboardTextSelectionController selectTextWithGranularity:atPoint:completionHandler:]
7 UIKit 0x18b895928 -[_UIKeyboardBasedNonEditableTextSelectionGestureController oneFingerForcePan:]
8 UIKit 0x18b91b59c -[UIGestureRecognizerTarget _sendActionWithGestureRecognizer:]
9 UIKit 0x18b91eca4 _UIGestureRecognizerSendTargetActions
10 UIKit 0x18b4e02e8 _UIGestureRecognizerSendActions
11 UIKit 0x18b37e828 -[UIGestureRecognizer _updateGestureWithEvent:buttonEvent:]
12 UIKit 0x18b90ece8 _UIGestureEnvironmentUpdate
13 CoreFoundation 0x18549f7dc __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__
14 CoreFoundation 0x18549d40c __CFRunLoopDoObservers
15 CoreFoundation 0x18549d89c __CFRunLoopRun
16 CoreFoundation 0x1853cc048 CFRunLoopRunSpecific
17 GraphicsServices 0x186e52198 GSEventRunModal
18 UIKit 0x18b3b82fc -[UIApplication _run]
19 UIKit 0x18b3b3034 UIApplicationMain
20 MyAppName 0x100050054 main (main.m:16)
21 libdispatch.dylib 0x1843b05b8 (Missing)
Can anyone please suggest me what can be the issue?
This kind of NSInvalidArgumentException, especially because it's on a private class, is probably due to a Zombie object. You are sending a message "setCursorPosition:" to an object that no longer exist, but another one is in it's place. In this case "_NSObserverList".
Try running with the "Zombie Objects" diagnostics objects to trace down which is the object that should receive that message but was gone. That option keeps the objects in memory when they are released, but marked as zombies.

Objective-C category for NSMutableDictionary not being respected in iOS10

I have an app written in Objective-C with a category for NSMutableDictionary. In iOS9, the app works fine. However when run in iOS10, the app crashes due to an 'unrecognized selector sent to instance'. I've isolated the problem to the NSMutableDictionary category not being respected in iOS10.
The category for NSMutableDictionary includes the following method:
- (id)getObjectForStringKeyPath:(NSString *)keysPath {
NSArray *dividedString = [keysPath componentsSeparatedByString:#"/"];
return [self getObjectForKeyPath:dividedString];
}
The line which it is crashing at is (response is type 'id'):
NSArray *textArray = [response getObjectForStringKeyPath:"someText/text"];
I've checked the response from the server and the response is valid. Also as I mentioned the crash does not happen on iOS9. It only happens on iOS10.
Does anyone know how to solve this, or any approaches to take for this problem?
Crash log
-[__NSSingleEntryDictionaryI getObjectForStringKeyPath:]: unrecognized selector sent to instance 0x608000a3f3e0
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSSingleEntryDictionaryI getObjectForStringKeyPath:]: unrecognized selector sent to instance 0x608000a3f3e0'
*** First throw call stack:
(
0 CoreFoundation 0x000000011036034b __exceptionPreprocess + 171
1 libobjc.A.dylib 0x000000010fdc121e objc_exception_throw + 48
2 CoreFoundation 0x00000001103cff34 -[NSObject(NSObject) doesNotRecognizeSelector:] + 132
3 CoreFoundation 0x00000001102e5c15 ___forwarding___ + 1013
4 CoreFoundation 0x00000001102e5798 _CF_forwarding_prep_0 + 120
5 XYZApp 0x000000010c919b7e __64-[XYZController configureConditionsTextFromHTML:]_block_invoke + 126
6 XYZApp 0x000000010c8e973f __41-[XYZDataProvider getTermsAndConditions:]_block_invoke + 159
7 XYZApp 0x000000010c8fd5ae -[XYZManager handleSuccessfulResponse:andResponseBlock:] + 110
8 XYZApp 0x000000010c8fbede __50-[XYZManager GET:withParameters:andResponseBlock:]_block_invoke + 126
9 libdispatch.dylib 0x0000000110872980 _dispatch_call_block_and_release + 12
10 libdispatch.dylib 0x000000011089c0cd _dispatch_client_callout + 8
11 libdispatch.dylib 0x000000011087ca1d _dispatch_main_queue_callback_4CF + 733
12 CoreFoundation 0x00000001103244f9 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
13 CoreFoundation 0x00000001102e9f8d __CFRunLoopRun + 2205
14 CoreFoundation 0x00000001102e9494 CFRunLoopRunSpecific + 420
15 GraphicsServices 0x00000001131c9a6f GSEventRunModal + 161
16 UIKit 0x000000010e573f34 UIApplicationMain + 159
17 XYZApp 0x000000010c92698f main + 111
18 libdyld.dylib 0x00000001108e868d start + 1
19 ??? 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
The error says that the object type is __NSSingleEntryDictionaryI, not the NSMutableDictionary that you expect.
Make a mutable copy of the dictionary that the server gives you and assign that to response.
For some undocumented reason, iOS10 believes the object type is an NSDictionary, so I created a category for NSDictionary with the getObjectForStringKeyPath method. This was the cleanest and most efficient solution for my problem.

CoreFoundation __exceptionPreprocess crash

I am getting a Fatal Exception: NSRangeException
*** -[__NSArrayM objectAtIndex:]: index 0 beyond bounds for empty array
But there is no call to removeObjectAtIndex, and this happens in different view controllers. I am just looking for ideas as to where to look since in lines 3-5 the App is given control but there are no symbols.
The crash log is from fabric/crashlytics and it only occurred around ~30 days from app release but the instance or number of crashes is relevant.
Thread : Fatal Exception: NSRangeException
0 CoreFoundation 0x00000001830502d8 __exceptionPreprocess + 132
1 libobjc.A.dylib 0x00000001948740e4 objc_exception_throw + 60
2 CoreFoundation 0x0000000182f3385c -[__NSArrayM removeObjectAtIndex:]
3 AppName 0x00000001000875b8
4 AppName 0x000000010008698c
5 AppName 0x00000001000867c4
6 libdispatch.dylib 0x0000000194ec5994 _dispatch_call_block_and_release + 24
7 libdispatch.dylib 0x0000000194ec5954 _dispatch_client_callout + 16
8 libdispatch.dylib 0x0000000194eca20c _dispatch_main_queue_callback_4CF + 1608
9 CoreFoundation 0x00000001830077f8 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 12
10 CoreFoundation 0x00000001830058a0 __CFRunLoopRun + 1492
11 CoreFoundation 0x0000000182f312d4 CFRunLoopRunSpecific + 396
12 GraphicsServices 0x000000018c7476fc GSEventRunModal + 168
13 UIKit 0x0000000187af6fac UIApplicationMain + 1488
14 AppName 0x000000010012e8cc
15 libdyld.dylib 0x0000000194ef2a08 start + 4

Crash in ios app

I included crashlytics in my ios app and distributed it via enterprise. Crashlytics keeps on reporting below crash daily regarding Reachability. I googled, but didn't get what causing this crash.
Fatal Exception: NSInvalidArgumentException
-[__NSMallocBlock__ reachabilityChanged:]: unrecognized selector sent to instance 0x1c5cdfc0
Thread : Fatal Exception: NSInvalidArgumentException
0 CoreFoundation 0x316642a3 __exceptionPreprocess + 162
1 libobjc.A.dylib 0x3252297f objc_exception_throw + 30
2 CoreFoundation 0x31667e07 -[NSObject(NSObject) doesNotRecognizeSelector:] + 170
3 CoreFoundation 0x31666531 ___forwarding___ + 392
4 CoreFoundation 0x315bdf68 _CF_forwarding_prep_0 + 24
5 CoreFoundation 0x315b5037 _CFXNotificationPost + 1426
6 Foundation 0x3319ed91 -[NSNotificationCenter postNotificationName:object:userInfo:] + 72
7 Foundation 0x331a2853 -[NSNotificationCenter postNotificationName:object:] + 30
8 0x0005aee9 ReachabilityCallback (Reachability.m:94)
9 SystemConfiguration 0x30f5f161 reachPerform + 924
10 CoreFoundation 0x31639683 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 14
11 CoreFoundation 0x31638ee9 __CFRunLoopDoSources0 + 212
12 CoreFoundation 0x31637cb7 __CFRunLoopRun + 646
13 CoreFoundation 0x315aaebd CFRunLoopRunSpecific + 356
14 CoreFoundation 0x315aad49 CFRunLoopRunInMode + 104
15 GraphicsServices 0x393a82eb GSEventRunModal + 74
16 UIKit 0x38e662f9 UIApplicationMain + 1120
17 0x00076f2f main (main.m:16)
18 libdyld.dylib 0x350bab20 start
It looks like you're registering a reachability observer which is being deallocated but not removing itself as an observer before that happens. So, when the reachability notification is posted later it is sent to a deallocated instance (i.e. random memory location) and you get a crash.
All observers (whether of reachability or any other notification with NSNotificationCenter) should remove themselves as an observer before they are deallocated.

App crashing on first use of UIImagePickerController

I am trying to use a UIImagePickerController in my app and am getting a crash after being prompted for access to the photo album for the first time. Here is the crash error:
[PUUIAlbumListViewController requiresAuth]: unrecognized selector sent to instance 0xd6a18b0
I can't find any references to this error anywhere. Anyone have any clues? Thanks!
-(void)showPicker
{
self.imagePicker = [[UIImagePickerController alloc]init];
self.imagePicker.delegate = self;
self.imagePicker.allowsEditing = NO;
self.imagePicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
self.imagePicker.mediaTypes = [UIImagePickerController availableMediaTypesForSourceType:UIImagePickerControllerSourceTypePhotoLibrary];
self.imagePicker.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
[self presentViewController:self.imagePicker animated:YES completion:nil];
}
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[PUUIAlbumListViewController requiresAuth]: unrecognized selector sent to instance 0xd1587d0'
*** First throw call stack:
(
0 CoreFoundation 0x03bcb5e4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x0394e8b6 objc_exception_throw + 44
2 CoreFoundation 0x03c68903 -[NSObject(NSObject) doesNotRecognizeSelector:] + 275
3 CoreFoundation 0x03bbb90b ___forwarding___ + 1019
4 CoreFoundation 0x03bbb4ee _CF_forwarding_prep_0 + 14
5 MyApp Mobile 0x000042e8 -[MyAppDelegate applicationDidBecomeActive:] + 2989
6 UIKit 0x027afef4 -[UIApplication _stopDeactivatingForReason:] + 329
7 UIKit 0x027b5afb _alertItemStateChanged + 81
8 CoreFoundation 0x03c27733 __CFNotificationCenterAddObserver_block_invoke + 163
9 CoreFoundation 0x03c27524 __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 20
10 CoreFoundation 0x03c277fd ____CFXNotificationPostToken_block_invoke + 173
11 CoreFoundation 0x03b8a1c0 __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ + 16
12 CoreFoundation 0x03b533f9 __CFRunLoopDoBlocks + 361
13 CoreFoundation 0x03b71843 __CFRunLoopRun + 2355
14 CoreFoundation 0x03b70ac3 CFRunLoopRunSpecific + 467
15 CoreFoundation 0x03b708db CFRunLoopRunInMode + 123
16 GraphicsServices 0x0477f9e2 GSEventRunModal + 192
17 GraphicsServices 0x0477f809 GSEventRun + 104
18 UIKit 0x027b6d3b UIApplicationMain + 1225
19 MyApp 0x00166361 main + 264
20 libdyld.dylib 0x0431e725 start + 0
)
libc++abi.dylib: terminating with uncaught exception of type NSException
It looks like the crash wasn't related to UIImagePickerController directly, but was occurring in the appdelegate on applicationDidBecomeActive when calling a selector on self.navigationController.visibleViewController without checking to see if the visibileViewController responded to the selector.
Somewhere your code is looking for a method: requiresAuth in your class: PUUIAlbumListViewController. It's not there. Code the missing method or remove the call to it.

Resources