App crashes with error unrecognized selector sent to instance - ios

I am having an unrecognized selector sent to instance issue. I know which line I am having problem with, but I don't understand why it doesn't recognize it. (I tested this code in when I was creating my container views and it works just fine. But for some reason when I merge it to my main project I am getting this error.)
This is my console output:
2013-12-20 16:47:59.633[8545:70b] -[UIViewController decideViewController:]: unrecognized selector sent to instance 0x8b5c250
2013-12-20 16:47:59.659[8545:70b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIViewController decideViewController:]: unrecognized selector sent to instance 0x8b5c250'
*** First throw call stack:
(
0 CoreFoundation 0x01c075e4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x0198a8b6 objc_exception_throw + 44
2 CoreFoundation 0x01ca4903 -[NSObject(NSObject) doesNotRecognizeSelector:] + 275
3 CoreFoundation 0x01bf790b ___forwarding___ + 1019
4 CoreFoundation 0x01bf74ee _CF_forwarding_prep_0 + 14
5 TProduct 0x0000566f -[GameViewController changeViews:] + 143
6 TProduct 0x00005404 -[GameViewController timerTick:] + 532
7 Foundation 0x015c1927 __NSFireTimer + 97
8 CoreFoundation 0x01bc5bd6 __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 22
9 CoreFoundation 0x01bc55bd __CFRunLoopDoTimer + 1181
10 CoreFoundation 0x01bad628 __CFRunLoopRun + 1816
11 CoreFoundation 0x01bacac3 CFRunLoopRunSpecific + 467
12 CoreFoundation 0x01bac8db CFRunLoopRunInMode + 123
13 GraphicsServices 0x0387b9e2 GSEventRunModal + 192
14 GraphicsServices 0x0387b809 GSEventRun + 104
15 UIKit 0x006f8d3b UIApplicationMain + 1225
16 TProduct 0x000070fd main + 141
17 libdyld.dylib 0x0224570d start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
and this is the part that it doesn't recognize
GameViewController.m
-(void)changeViews:(NSString *)gameStateSegueIdentifier
{
NSLog(#"show view gameStateSegueIdentifier :%#",gameStateSegueIdentifier);
[self.containerController decideViewController:gameStateSegueIdentifier];
}
and this is the method I am calling
ContainerViewController.m
-(void)decideViewController:(NSString *)gameStateSegueIdentifier
{
if (gameStateSegueIdentifier == _currentSegueIdentifier) {
return;
}
while (gameStateSegueIdentifier != _currentSegueIdentifier) {
NSLog(#"this is the gameStateSegueIdentifier %#",gameStateSegueIdentifier);
NSLog(#"this is the currentSegueIdentifier %#",_currentSegueIdentifier);
[self changeViewControllers];
}
}
I understand that there are lots of "unrecognized selector sent to instance" questions already. But so far, I wasn't able to find an answer for my case. I appreciate the help.

The error message you're getting explains the problem:
2013-12-20 16:47:59.633[8545:70b] -[UIViewController decideViewController:]: unrecognized selector sent to instance 0x8b5c250
This is telling you that an instance of the class UIViewController got the message decideViewController:. UIViewController does not respond to this message. So, it seems that self.containerController is a UIViewController rather than a ContainerViewController. (If it was a ContainerViewController, it would say so in the error message.)
The fact that the property is declared as a ContainerViewController doesn't mean that there's actually a ContainerViewController in it. Go to where you actually create this object and assign it to that property, and ensure you're creating it as the correct class.

when the selector is not recognized you don't need to show the code for the selector, because it is not executed.
Show the property line of containerController.
Are you 100% sure that self.containerController is a ContainerViewController, your error message shows a UIViewController, so you are doing something special like cluster or a category?
Are you using #import "ContainerViewController"?
Is the method in the #implementation #end part?

Related

iOS app crashing on [NSNull hasColorGlyphsInRange:attributes:]

I'm facing this exception, and i'm not being able to figure out the problem.
i tried adding exception breakpoint and symbolic breakpoint but it didn't show any more useful data. it's crashing on the main.h return with nothing in the backtrace
this is the exception:
2016-10-20 17:32:58.615 <AppName>[15655:3398242] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSNull hasColorGlyphsInRange:attributes:]: unrecognized selector sent to instance 0x10b1acfb0'
*** First throw call stack:
(
0 CoreFoundation 0x000000010aeef34b __exceptionPreprocess + 171
1 libobjc.A.dylib 0x000000010f90221e objc_exception_throw + 48
2 CoreFoundation 0x000000010af5ef34 -[NSObject(NSObject) doesNotRecognizeSelector:] + 132
3 CoreFoundation 0x000000010ae74c15 ___forwarding___ + 1013
4 CoreFoundation 0x000000010ae74798 _CF_forwarding_prep_0 + 120
5 UIKit 0x000000010d9c66c1 -[UILabel _determineContentsFormat] + 1475
6 UIKit 0x000000010d9c6f9d -[UILabel _evaluateContentsFormat] + 33
7 UIKit 0x000000010d801923 -[UIView(CALayerDelegate) layerWillDraw:] + 65
8 QuartzCore 0x000000010d2c0b26 _ZN2CA5Layer8display_Ev + 146
9 QuartzCore 0x000000010d2b5596 _ZN2CA5Layer17display_if_neededEPNS_11TransactionE + 294
10 QuartzCore 0x000000010d2b5629 _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 35
11 QuartzCore 0x000000010d24362c _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 280
12 QuartzCore 0x000000010d270713 _ZN2CA11Transaction6commitEv + 475
13 QuartzCore 0x000000010d271083 _ZN2CA11Transaction17observer_callbackEP19__CFRunLoopObservermPv + 113
14 CoreFoundation 0x000000010ae93e17 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 23
15 CoreFoundation 0x000000010ae93d87 __CFRunLoopDoObservers + 391
16 CoreFoundation 0x000000010ae78b9e __CFRunLoopRun + 1198
17 CoreFoundation 0x000000010ae78494 CFRunLoopRunSpecific + 420
18 GraphicsServices 0x0000000111c6fa6f GSEventRunModal + 161
19 UIKit 0x000000010d73df34 UIApplicationMain + 159
20 AppName 0x0000000109998c73 main + 1187
21 libdyld.dylib 0x00000001103f368d start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
'-[NSNull hasColorGlyphsInRange:attributes:]: unrecognized selector sent to instance 0x10b1acfb0'
This means you've used a NSNull object. From the call stack, maybe a NSNull used as NSString or NSAttributedString. So you need check it before use it.
if (str != [NSNull null]) {
label.text = str
}
are you use this function hasColorGlyphsInRange if you use
try
if ([self respondsToSelector:#selector(hasColorGlyphsInRange:)]) {
//code
}
You need to be able to read and understand error messages.
You are told that someone or something tried to send a message hasColorGlyphsInRange to an instance of NSNull. Even if it is hard to accept because that shouldn't happen, that's the error message and that's what happened.
So you have put an NSNull instance somewhere where you shouldn't have. hasColorGlyphsInRange doesn't seem documented anywhere, so it's something internal to iOS or macOS. But it very much looks like something about text, and there are UILabel methods on the call stack. And there is a layerWillDraw: on the call stack, so it's something trying to draw a UILabel.
UILabels don't get redrawn immediately, but when the system decides to redraw anything. So the most likely thing is that you have set the text of a UILabel to an NSNull object.
And where does the NSNull object come from? Bets are that you are processing JSON and you assume that you are getting a string and don't check for null objects, and that's why you are setting the text of some UILabel to an NSNull instance.

Segment framework make UIAlertController to crash

I follow "https://segment.com/" to implement analytics user usage on my iOS source. But when i use UIAlertController to show alert with title is #"", my app was crash! I don't know exactly why. To solve it, i must set title of alert is nil. And this is my logs:
2016-11-10 17:12:57.185 Lightning Rider Partner[24434:236155] *** Assertion failure in -[SEGAnalytics screen:properties:options:](), /Users/dungdo/Desktop/tcourier-ios/v2_driver/Pods/Analytics/Analytics/Classes/SEGAnalytics.m:323
2016-11-10 17:12:57.192 Lightning Rider Partner[24434:236155] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'screen name () must not be empty.'
*** First throw call stack:
(
0 CoreFoundation 0x000000010c1f134b __exceptionPreprocess + 171
1 libobjc.A.dylib 0x00000001120f521e objc_exception_throw + 48
2 CoreFoundation 0x000000010c1f5442 +[NSException raise:format:arguments:] + 98
3 Foundation 0x0000000111cc1d79 -[NSAssertionHandler handleFailureInFunction:file:lineNumber:description:] + 166
4 Analytics 0x000000010bc29d37 -[SEGAnalytics screen:properties:options:] + 471
5 Analytics 0x000000010bc3fb7c -[UIViewController(SEGScreen) seg_viewDidAppear:] + 444
6 UIKit 0x000000010e50eb0c -[UIViewController _setViewAppearState:isAnimating:] + 945
7 UIKit 0x000000010e51187a __64-[UIViewController viewDidMoveToWindow:shouldAppearOrDisappear:]_block_invoke + 42
8 UIKit 0x000000010e50fb64 -[UIViewController _executeAfterAppearanceBlock] + 86
9 UIKit 0x000000010e374438 _runAfterCACommitDeferredBlocks + 653
10 UIKit 0x000000010e360f6f _cleanUpAfterCAFlushAndRunDeferredBlocks + 566
11 UIKit 0x000000010e3923da _afterCACommitHandler + 176
12 CoreFoundation 0x000000010c195e17 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 23
13 CoreFoundation 0x000000010c195d87 __CFRunLoopDoObservers + 391
14 CoreFoundation 0x000000010c17ab9e __CFRunLoopRun + 1198
15 CoreFoundation 0x000000010c17a494 CFRunLoopRunSpecific + 420
16 GraphicsServices 0x0000000115145a6f GSEventRunModal + 161
17 UIKit 0x000000010e367964 UIApplicationMain + 159
18 Lightning Rider Partner 0x000000010ad74c3f main + 111
19 libdyld.dylib 0x00000001128a868d start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
I was getting the same issue while using the Segment framework.
I just comment the Assert statement in SDK file for empty screen. Please search line below in your whole project and comment it out.
NSCAssert1(screenTitle.length > 0, #"screen name (%#) must not be empty.", screenTitle);
You are good to go.
This seems like the error Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'screen name () must not be empty.
Make sure you already set it while creating SEGAnalytics class or something related

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.

error with Core Data and iCloud

I am trying to work with Core Data and iCloud.
It worked once and it did not again.
I got this error below :
2015-05-19 12:11:13.695 Student Notebook App[34617:992535] -[Student_Notebook_App.NotebookTableView persistentStoreWillChange]: unrecognized selector sent to instance 0x7f86495514b0
2015-05-19 12:11:13.737 Student Notebook App[34617:992535] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[Student_Notebook_App.NotebookTableView persistentStoreWillChange]: unrecognized selector sent to instance 0x7f86495514b0'
*** First throw call stack:
(
0 CoreFoundation 0x0000000110638c65 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x000000010ff15bb7 objc_exception_throw + 45
2 CoreFoundation 0x00000001106400ad -[NSObject(NSObject) doesNotRecognizeSelector:] + 205
3 CoreFoundation 0x000000011059613c ___forwarding___ + 988
4 CoreFoundation 0x0000000110595cd8 _CF_forwarding_prep_0 + 120
5 CoreFoundation 0x000000011060854c __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 12
6 CoreFoundation 0x0000000110506a04 _CFXNotificationPost + 2484
7 Foundation 0x000000010fa6c968 -[NSNotificationCenter postNotificationName:object:userInfo:] + 66
8 CoreData 0x0000000110303d5b __81-[PFUbiquitySetupAssistant tryToReplaceLocalStore:withStoreSideLoadedByImporter:]_block_invoke + 283
9 libdispatch.dylib 0x00000001131f5614 _dispatch_client_callout + 8
10 libdispatch.dylib 0x00000001131e02fa _dispatch_barrier_sync_f_slow_invoke + 275
11 libdispatch.dylib 0x00000001131f5614 _dispatch_client_callout + 8
12 libdispatch.dylib 0x00000001131dda1c _dispatch_main_queue_callback_4CF + 1664
13 CoreFoundation 0x00000001105a01f9 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
14 CoreFoundation 0x0000000110561dcb __CFRunLoopRun + 2043
15 CoreFoundation 0x0000000110561366 CFRunLoopRunSpecific + 470
16 GraphicsServices 0x0000000114e91a3e GSEventRunModal + 161
17 UIKit 0x0000000110c73900 UIApplicationMain + 1282
18 Student Notebook App 0x000000010f923aa7 main + 135
19 libdyld.dylib 0x0000000113229145 start + 1
20 ??? 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
Please, anyone can help me??
Thanks in Advance
The error is pretty clear:
-[Student_Notebook_App.NotebookTableView persistentStoreWillChange]: unrecognized selector sent to instance 0x7f86495514b0
This says that your code is trying to call a method named persistentStoreWillChange on a class that doesn't have that method.
The stack trace indicates that this happened when a notification was posted. It doesn't say which one. What happened is:
You registered to observe a notification with a method named persistentStoreWillChange.
Later that notification was posted. The notification system tried to call persistentStoreWillChange, but the method did not exist.
When you register for a notification, the callback method name that you provide must exist.

App Invites for friends in Facebook using iOS 8.2 "unrecognized selector sent to instance"

I followed facebook documents to develop invite friend to ios app from here: App Invites for iOS ... Here is my code:
#implementation ViewController
FBSDKAppInviteContent *content;
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
content =[[FBSDKAppInviteContent alloc] initWithAppLinkURL:[NSURL URLWithString:#"https://fb.me/1569122770021958"]];
//optionally set previewImageURL
content.previewImageURL = [NSURL URLWithString:#"http://www.jpl.nasa.gov/spaceimages/images/mediumsize/PIA17011_ip.jpg"];
}
And then I have defined an action button as follow:
- (IBAction)InviteFriends:(id)sender {
// present the dialog. Assumes self implements protocol `FBSDKAppInviteDialogDelegate`
[FBSDKAppInviteDialog showWithContent:content delegate:sender];
}
However I received an error as follow:
2015-04-30 19:09:06.850 LoopApp[6338:120645] -[UIButton appInviteDialog:didCompleteWithResults:]: unrecognized selector sent to instance 0x7fbdd870f9d0
2015-04-30 19:09:06.852 LoopApp[6338:120645] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIButton appInviteDialog:didCompleteWithResults:]: unrecognized selector sent to instance 0x7fbdd870f9d0'
It says I haven't defined appInviteDialog:didCompleteWithResults: so I added this method as follow:
- (void) appInviteDialog: (FBSDKAppInviteDialog *)appInviteDialoge didFailWithError:(NSError *)error
{
NSLog(#"Session connection failed with error %#",[error self]);
}
I can go all the steps to select my friends and when I press button to share it shares but when it wants to go back to app crashes and it give me same error as above. I appreciate if anyone can help me why this is happening.
-[UIButton appInviteDialog:didCompleteWithResults:]: unrecognized selector sent to instance 0x7fabc3dbb840
2015-04-30 19:23:29.305 LoopApp[6423:125823] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIButton appInviteDialog:didCompleteWithResults:]: unrecognized selector sent to instance 0x7fabc3dbb840'
*** First throw call stack:
(
0 CoreFoundation 0x000000010ed0ea75 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x000000010e5febb7 objc_exception_throw + 45
2 CoreFoundation 0x000000010ed15d1d -[NSObject(NSObject) doesNotRecognizeSelector:] + 205
3 CoreFoundation 0x000000010ec6d9dc ___forwarding___ + 988
4 CoreFoundation 0x000000010ec6d578 _CF_forwarding_prep_0 + 120
5 LoopApp 0x000000010dfb71e1 -[FBSDKAppInviteDialog _invokeDelegateDidCompleteWithResults:] + 297
6 LoopApp 0x000000010dfb70a5 -[FBSDKAppInviteDialog _handleCompletionWithDialogResults:error:] + 67
7 LoopApp 0x000000010dfb6ed9 __28-[FBSDKAppInviteDialog show]_block_invoke + 131
8 LoopApp 0x000000010df92f51 -[FBSDKApplicationDelegate applicationDidBecomeActive:] + 194
9 CoreFoundation 0x000000010ecde7fc __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 12
10 CoreFoundation 0x000000010ebde204 _CFXNotificationPost + 2484
11 Foundation 0x000000010e158df8 -[NSNotificationCenter postNotificationName:object:userInfo:] + 66
12 UIKit 0x000000010f33bfc8 -[UIApplication _stopDeactivatingForReason:] + 363
13 UIKit 0x000000010f350ea2 -[UIApplication _handleNonLaunchSpecificActions:forScene:withTransitionContext:] + 2648
14 FrontBoardServices 0x0000000112831243 __31-[FBSSerialQueue performAsync:]_block_invoke + 16
15 CoreFoundation 0x000000010ec43c7c __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ + 12
16 CoreFoundation 0x000000010ec399c5 __CFRunLoopDoBlocks + 341
17 CoreFoundation 0x000000010ec39785 __CFRunLoopRun + 2389
18 CoreFoundation 0x000000010ec38bc6 CFRunLoopRunSpecific + 470
19 GraphicsServices 0x0000000113230a58 GSEventRunModal + 161
20 UIKit 0x000000010f341580 UIApplicationMain + 1282
21 LoopApp 0x000000010df88f93 main + 115
22 libdyld.dylib 0x00000001114ff145 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
The problem is that you are setting your button as the delegate for the FBSDKAppInviteDialog. The UIButton does not conform to the FBSDKAppInviteDialogDelegate protocol and therefore it crashes.
To fix this, change your code so that the delegate is nil or self (if self conforms to the FBSDKAppInviteDialogDelegate protocol):
- (IBAction)InviteFriends:(id)sender {
[FBSDKAppInviteDialog showWithContent:content delegate:self];
}

Resources