Objective-C: unrecognized selector sent to instance 0xba3e750 - ios

I have written this code and when I run the program it throws exception: unrecognized selector sent to instance 0xba3e750
storyboard = [UIStoryboard storyboardWithName:#"Main" bundle:nil];
navigationController = [storyboard instantiateViewControllerWithIdentifier:#"SecondViewID"];
selected = navigationController.viewControllers[0];
when I put this line in comment
//selected = navigationController.viewControllers[0];
like that , the program doesn't throw exception.
this is whole exception
2014-06-12 20:59:44.749 passing image[2194:a0b] -[SecondViewController viewControllers]: unrecognized selector sent to instance 0xba3e750
2014-06-12 20:59:44.753 passing image[2194:a0b] * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[SecondViewController viewControllers]: unrecognized selector sent to instance 0xba3e750'
* First throw call stack:
(
0 CoreFoundation 0x017445e4 exceptionPreprocess + 180
1 libobjc.A.dylib 0x014c78b6 objc_exception_throw + 44
2 CoreFoundation 0x017e1903 -[NSObject(NSObject) doesNotRecognizeSelector:] + 275
3 CoreFoundation 0x0173490b ___forwarding_ + 1019
4 CoreFoundation 0x017344ee _CF_forwarding_prep_0 + 14
5 passing image 0x000056a2 -[ViewController viewDidLoad] + 466
6 UIKit 0x00349318 -[UIViewController loadViewIfRequired] + 696
7 UIKit 0x003495b4 -[UIViewController view] + 35
8 UIKit 0x002719fd -[UIWindow addRootViewControllerViewIfPossible] + 66
9 UIKit 0x00271d97 -[UIWindow _setHidden:forced:] + 312
10 UIKit 0x0027202d -[UIWindow _orderFrontWithoutMakingKey] + 49
11 UIKit 0x0027c89a -[UIWindow makeKeyAndVisible] + 65
12 UIKit 0x0022fcd0 -[UIApplication _callInitializationDelegatesForURL:payload:suspended:] + 1851
13 UIKit 0x002343a8 -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 824
14 UIKit 0x0024887c -[UIApplication handleEvent:withNewEvent:] + 3447
15 UIKit 0x00248de9 -[UIApplication sendEvent:] + 85
16 UIKit 0x00236025 _UIApplicationHandleEvent + 736
17 GraphicsServices 0x037932f6 _PurpleEventCallback + 776
18 GraphicsServices 0x03792e01 PurpleEventCallback + 46
19 CoreFoundation 0x016bfd65 CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION + 53
20 CoreFoundation 0x016bfa9b __CFRunLoopDoSource1 + 523
21 CoreFoundation 0x016ea77c __CFRunLoopRun + 2156
22 CoreFoundation 0x016e9ac3 CFRunLoopRunSpecific + 467
23 CoreFoundation 0x016e98db CFRunLoopRunInMode + 123
24 UIKit 0x00233add -[UIApplication _run] + 840
25 UIKit 0x00235d3b UIApplicationMain + 1225
26 passing image 0x0000750d main + 141
27 libdyld.dylib 0x01e78725 start + 0
28 ??? 0x00000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)

instantiateViewControllerWithIdentifier: returns a UIViewController, but you're storing it in a UINavigationController when you shouldn't. When you try to access a UINavigationController property (viewControllers), it crashed because UIViewController doesn't have a property named viewControllers.
Try storing the return of the method instantiateViewControllerWithIdentifier: in a UIViewController instead of a UINavigationController :
UIViewController * viewController = [storyboard instantiateViewControllerWithIdentifier:#"SecondViewID"];
selected = viewController.navigationController.viewControllers[0];

Related

Swift: Not able to navigate to another view controller

I really do not know what mistake am I doing in the following lines:
// Instantiate SecondViewController
let secondViewController = self.storyboard?.instantiateViewController(withIdentifier: "RegistrationScreen2View") as! RegistrationScreen2ViewController
self.navigationController?.pushViewController(secondViewController, animated: true)
I am not able to move to second view controller in the story board I have mentioned story board id as RegistrationScreen2View for RegistrationScreen2ViewController.
I am getting the following exception:
2016-10-24 11:26:16.607 toadways[965:11142] -[toadways.RegistrationScreen1ViewController continue]: unrecognized selector sent to instance 0x7fe05dc34ec0
2016-10-24 11:26:16.619 toadways[965:11142] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[toadways.RegistrationScreen1ViewController continue]: unrecognized selector sent to instance 0x7fe05dc34ec0'
*** First throw call stack:
(
0 CoreFoundation 0x000000010efa534b __exceptionPreprocess + 171
1 libobjc.A.dylib 0x000000010ea0621e objc_exception_throw + 48
2 CoreFoundation 0x000000010f014f34 -[NSObject(NSObject) doesNotRecognizeSelector:] + 132
3 CoreFoundation 0x000000010ef2ac15 ___forwarding___ + 1013
4 CoreFoundation 0x000000010ef2a798 _CF_forwarding_prep_0 + 120
5 UIKit 0x000000010f3cab88 -[UIApplication sendAction:to:from:forEvent:] + 83
6 UIKit 0x000000010f5502b2 -[UIControl sendAction:to:forEvent:] + 67
7 UIKit 0x000000010f5505cb -[UIControl _sendActionsForEvents:withEvent:] + 444
8 UIKit 0x000000010f54f4c7 -[UIControl touchesEnded:withEvent:] + 668
9 UIKit 0x000000010f4380d5 -[UIWindow _sendTouchesForEvent:] + 2747
10 UIKit 0x000000010f4397c3 -[UIWindow sendEvent:] + 4011
11 UIKit 0x000000010f3e6a33 -[UIApplication sendEvent:] + 371
12 UIKit 0x000000010fbd8b6d __dispatchPreprocessedEventFromEventQueue + 3248
13 UIKit 0x000000010fbd1817 __handleEventQueue + 4879
14 CoreFoundation 0x000000010ef4a311 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
15 CoreFoundation 0x000000010ef2f59c __CFRunLoopDoSources0 + 556
16 CoreFoundation 0x000000010ef2ea86 __CFRunLoopRun + 918
17 CoreFoundation 0x000000010ef2e494 CFRunLoopRunSpecific + 420
18 GraphicsServices 0x0000000116c0ca6f GSEventRunModal + 161
19 UIKit 0x000000010f3c8f34 UIApplicationMain + 159
20 toadways 0x000000010e2318bf main + 111
21 libdyld.dylib 0x000000011266368d start + 1
22 ??? 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
Please let me know what mistake am I doing.
Your code should work. The most possibility is that you forgot to input an Storyboard ID for your destination ViewController.
***How to Fix:
In the Identity Inspector of destination ViewController, enter its ID.

ibc++abi.dylib: terminating with uncaught exception of type NSException (lldb)

when i run my app, i received this error :
2014-11-10 06:14:05.581 Yoga[4032:110484] user is registered
2014-11-10 06:14:30.552 Yoga[4032:110484] * Terminating app due to uncaught exception 'NSGenericException', reason: 'Push segues can only be used when the source controller is managed by an instance of UINavigationController.'
* First throw call stack:
(
0 CoreFoundation 0x000000010c999f35 exceptionPreprocess + 165
1 libobjc.A.dylib 0x000000010c632bb7 objc_exception_throw + 45
2 UIKit 0x000000010b43e16a -[UIStoryboardPushSegue destinationContainmentContext] + 0
3 UIKit 0x000000010aedc8be -[UIApplication sendAction:to:from:forEvent:] + 75
4 UIKit 0x000000010afe3410 -[UIControl _sendActionsForEvents:withEvent:] + 467
5 UIKit 0x000000010afe27df -[UIControl touchesEnded:withEvent:] + 522
6 UIKit 0x000000010af22308 -[UIWindow _sendTouchesForEvent:] + 735
7 UIKit 0x000000010af22c33 -[UIWindow sendEvent:] + 683
8 UIKit 0x000000010aeef9b1 -[UIApplication sendEvent:] + 246
9 UIKit 0x000000010aefca7d _UIApplicationHandleEventFromQueueEvent + 17370
10 UIKit 0x000000010aed8103 _UIApplicationHandleEventQueue + 1961
11 CoreFoundation 0x000000010c8cf551 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION + 17
12 CoreFoundation 0x000000010c8c541d __CFRunLoopDoSources0 + 269
13 CoreFoundation 0x000000010c8c4a54 __CFRunLoopRun + 868
14 CoreFoundation 0x000000010c8c4486 CFRunLoopRunSpecific + 470
15 GraphicsServices 0x000000010d3329f0 GSEventRunModal + 161
16 UIKit 0x000000010aedb420 UIApplicationMain + 1282
17 Yoga 0x000000010a840b53 main + 115
18 libdyld.dylib 0x000000010f69b145 start + 1
19 ??? 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
somebody can help me pls
add Navigation Controller to your initial view
Select the initial view
Go To Editor--> Embed In --> Navigation Controller.

Objective C++, SIGABRT signal

Im doing an iOS app(actually just copying code) from this tutorial http://hubpages.com/hub/Tutorial-on-Creating-an-IOS-5-SQLite-Database-Application-IOS-5-SQLite
and I can't run my app. Build succeds and then I get signal SIGABRT in my XCode.
2014-08-28 09:04:40.105 Whine2[526:60b] Problem with prepare statement
2014-08-28 09:04:40.109 Whine2[526:60b] *** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayM objectAtIndex:]: index 0 beyond bounds for empty array'
*** First throw call stack:
(
0 CoreFoundation 0x018d81e4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x016578e5 objc_exception_throw + 44
2 CoreFoundation 0x018793f6 -[__NSArrayM objectAtIndex:] + 246
3 Whine2 0x000029bd -[kcbViewController viewDidLoad] + 269
4 UIKit 0x0043633d -[UIViewController loadViewIfRequired] + 696
5 UIKit 0x004365d9 -[UIViewController view] + 35
6 UIKit 0x00356267 -[UIWindow addRootViewControllerViewIfPossible] + 66
7 UIKit 0x003565ef -[UIWindow _setHidden:forced:] + 312
8 UIKit 0x0035686b -[UIWindow _orderFrontWithoutMakingKey] + 49
9 UIKit 0x003613c8 -[UIWindow makeKeyAndVisible] + 65
10 UIKit 0x00311bc0 -[UIApplication _callInitializationDelegatesForURL:payload:suspended:] + 2097
11 UIKit 0x00316667 -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 824
12 UIKit 0x0032af92 -[UIApplication handleEvent:withNewEvent:] + 3517
13 UIKit 0x0032b555 -[UIApplication sendEvent:] + 85
14 UIKit 0x00318250 _UIApplicationHandleEvent + 683
15 GraphicsServices 0x038cdf02 _PurpleEventCallback + 776
16 GraphicsServices 0x038cda0d PurpleEventCallback + 46
17 CoreFoundation 0x01853ca5 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 53
18 CoreFoundation 0x018539db __CFRunLoopDoSource1 + 523
19 CoreFoundation 0x0187e68c __CFRunLoopRun + 2156
20 CoreFoundation 0x0187d9d3 CFRunLoopRunSpecific + 467
21 CoreFoundation 0x0187d7eb CFRunLoopRunInMode + 123
22 UIKit 0x00315d9c -[UIApplication _run] + 840
23 UIKit 0x00317f9b UIApplicationMain + 1225
24 Whine2 0x0000282d main + 141
25 libdyld.dylib 0x01e21701 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
I understand there is some problem with array, right?
As your error message and code in the link says, there is one array named wines in viewDidLoad of kcbViewController and it is empty. aJust log the array wines before accessing it . If you need to check whether an array is empty, you can check if self.wines.count is 0.

Present UIViewController from subclass of UIView

I have created a subclass of UIView, Now in my app i need to present a UIViewController from it,
I have tried following :
poiInfoController = [[poiInfoController alloc]initWithNibName:#"poiInfoController" bundle:nil];
[poiInfoController setModalPresentationStyle:UIModalPresentationFormSheet];
[[[[UIApplication sharedApplication] keyWindow] rootViewController] presentModalViewController:poiInfoController animated:YES];
but it will crash with Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Application tried to present modally an active controller .'
Please Help,
**EDIT CRASH LOG:**
2014-04-23 17:04:26.433 NavigationLibSprintMoM[4610:a0b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Application tried to present modally an active controller <ViewController: 0x9d52140>.'
*** First throw call stack:
(
0 CoreFoundation 0x017c15e4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x014d08b6 objc_exception_throw + 44
2 UIKit 0x0036217a -[UIViewController presentViewController:withTransition:completion:] + 4879
3 UIKit 0x00362caf -[UIViewController presentViewController:animated:completion:] + 130
4 NavigationLibSprintMoM 0x00005f7b -[NavigationView handleGesture:] + 964
5 UIKit 0x005baf8c _UIGestureRecognizerSendActions + 230
6 UIKit 0x005b9c00 -[UIGestureRecognizer _updateGestureWithEvent:buttonEvent:] + 383
7 UIKit 0x005bb66d -[UIGestureRecognizer _delayedUpdateGesture] + 60
8 UIKit 0x005bebcd ___UIGestureRecognizerUpdate_block_invoke + 57
9 UIKit 0x005beb4e _UIGestureRecognizerRemoveObjectsFromArrayAndApplyBlocks + 317
10 UIKit 0x005b5248 _UIGestureRecognizerUpdate + 199
11 UIKit 0x00281d4a -[UIWindow _sendGesturesForEvent:] + 1291
12 UIKit 0x00282c6a -[UIWindow sendEvent:] + 1030
13 UIKit 0x00256a36 -[UIApplication sendEvent:] + 242
14 UIKit 0x00240d9f _UIApplicationHandleEventQueue + 11421
15 CoreFoundation 0x0174a8af __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15
16 CoreFoundation 0x0174a23b __CFRunLoopDoSources0 + 235
17 CoreFoundation 0x0176730e __CFRunLoopRun + 910
18 CoreFoundation 0x01766b33 CFRunLoopRunSpecific + 467
19 CoreFoundation 0x0176694b CFRunLoopRunInMode + 123
20 GraphicsServices 0x038699d7 GSEventRunModal + 192
21 GraphicsServices 0x038697fe GSEventRun + 104
22 UIKit 0x0024394b UIApplicationMain + 1225
23 NavigationLibSprintMoM 0x0000374d main + 141
24 libdyld.dylib 0x01f54725 start + 0
25 ??? 0x00000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException

Unwind segue issue when navigating back to parent scene

I'm trying to unwind segue form a scene. It works fine but I need to get a value to the parent screen. (I use the push segue to navigate from parent to child scene)
I'm calling the unwind segue like this
- (IBAction)done:(UIStoryboardSegue *)segue {
NSLog(#"gonna navigate");
RESTToppingTableViewController *vc = [segue destinationViewController];
[self setSelectedToppings:[vc toppingList]];
NSLog(#"%#", [vc toppingList]);
}
But the issue is, it seems the toppingList array is removed from memory even before the parent view is called.
Below is the error I got.
2013-12-06 13:26:42.192 Pizza to Go[2319:a0b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[RESTAddToCartViewController toppingList]: unrecognized selector sent to instance 0x9b681a0'
*** First throw call stack:
(
0 CoreFoundation 0x01f405e4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x01cc38b6 objc_exception_throw + 44
2 CoreFoundation 0x01fdd903 -[NSObject(NSObject) doesNotRecognizeSelector:] + 275
3 CoreFoundation 0x01f3090b ___forwarding___ + 1019
4 CoreFoundation 0x01f304ee _CF_forwarding_prep_0 + 14
5 Pizza to Go 0x0004a3a2 -[RESTAddToCartViewController done:] + 130
6 libobjc.A.dylib 0x01cd581f -[NSObject performSelector:withObject:] + 70
7 UIKit 0x010d01f1 -[UIStoryboardUnwindSegueTemplate _perform:] + 536
8 UIKit 0x00f660f9 -[UIStoryboardSegueTemplate perform:] + 115
9 libobjc.A.dylib 0x01cd5874 -[NSObject performSelector:withObject:withObject:] + 77
10 UIKit 0x00a330c2 -[UIApplication sendAction:to:from:forEvent:] + 108
11 UIKit 0x00d07c9b -[UIBarButtonItem(UIInternal) _sendAction:withEvent:] + 139
12 libobjc.A.dylib 0x01cd5874 -[NSObject performSelector:withObject:withObject:] + 77
13 UIKit 0x00a330c2 -[UIApplication sendAction:to:from:forEvent:] + 108
14 UIKit 0x00a3304e -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 61
15 UIKit 0x00b2b0c1 -[UIControl sendAction:to:forEvent:] + 66
16 UIKit 0x00b2b484 -[UIControl _sendActionsForEvents:withEvent:] + 577
17 UIKit 0x00b2a733 -[UIControl touchesEnded:withEvent:] + 641
18 UIKit 0x00a7051d -[UIWindow _sendTouchesForEvent:] + 852
19 UIKit 0x00a71184 -[UIWindow sendEvent:] + 1232
20 UIKit 0x00a44e86 -[UIApplication sendEvent:] + 242
21 UIKit 0x00a2f18f _UIApplicationHandleEventQueue + 11421
22 CoreFoundation 0x01ec983f __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15
23 CoreFoundation 0x01ec91cb __CFRunLoopDoSources0 + 235
24 CoreFoundation 0x01ee629e __CFRunLoopRun + 910
25 CoreFoundation 0x01ee5ac3 CFRunLoopRunSpecific + 467
26 CoreFoundation 0x01ee58db CFRunLoopRunInMode + 123
27 GraphicsServices 0x03e159e2 GSEventRunModal + 192
28 GraphicsServices 0x03e15809 GSEventRun + 104
29 UIKit 0x00a31d3b UIApplicationMain + 1225
30 Pizza to Go 0x000574ad main + 141
31 libdyld.dylib 0x0285e725 start + 0
)
libc++abi.dylib: terminating with uncaught exception of type NSException
What could be the possible fix? thanks for your time in advance.
I'm not sure but I think your destinationViewController isn't a RESTToppingTableViewController.
The log:
-[RESTAddToCartViewController toppingList]:
unrecognized selector sent to instance 0x9b681a0
states that you are trying to get the toppingList of a RESTAddToCartViewController but this controller has no toppingList property.
Make sure that the UIViewController returned by [segue destinationViewController] really is what you are expecting.

Resources