Swift: Not able to navigate to another view controller - ios

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.

Related

"Show" Segue made from dragging button to view controller throws error

Here's what I did: I control dragged from the button to the viewController and starting the app is fine. However, when I click the "let's get started" button, which should segue into the next part of the app, I just get an error. What am I doing wrong?
Latest version of xcode (not beta) and code I wrote (I didn't write any code for the segue though) was in swift.
Also, the error message I'm getting
Registration for remote notification failed with error: REMOTE_NOTIFICATION_SIMULATOR_NOT_SUPPORTED_NSERROR_DESCRIPTION
2016-07-28 14:20:53.108 TouchLogin[6368:503476] -[TouchLogin.BWWalkthroughPageViewController GetStarted:]: unrecognized selector sent to instance 0x7f8cc351b360
2016-07-28 14:20:53.111 TouchLogin[6368:503476] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[TouchLogin.BWWalkthroughPageViewController GetStarted:]: unrecognized selector sent to instance 0x7f8cc351b360'
*** First throw call stack:
(
0 CoreFoundation 0x000000010132bd85 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x0000000103310deb objc_exception_throw + 48
2 CoreFoundation 0x0000000101334d3d -[NSObject(NSObject) doesNotRecognizeSelector:] + 205
3 CoreFoundation 0x000000010127acfa ___forwarding___ + 970
4 CoreFoundation 0x000000010127a8a8 _CF_forwarding_prep_0 + 120
5 UIKit 0x0000000101d96a8d -[UIApplication sendAction:to:from:forEvent:] + 92
6 UIKit 0x0000000101f09e67 -[UIControl sendAction:to:forEvent:] + 67
7 UIKit 0x0000000101f0a143 -[UIControl _sendActionsForEvents:withEvent:] + 327
8 UIKit 0x0000000101f09263 -[UIControl touchesEnded:withEvent:] + 601
9 UIKit 0x000000010227ec52 _UIGestureRecognizerUpdate + 10279
10 UIKit 0x0000000101e0948e -[UIWindow _sendGesturesForEvent:] + 1137
11 UIKit 0x0000000101e0a6c4 -[UIWindow sendEvent:] + 849
12 UIKit 0x0000000101db5dc6 -[UIApplication sendEvent:] + 263
13 UIKit 0x0000000101d8f553 _UIApplicationHandleEventQueue + 6660
14 CoreFoundation 0x0000000101251301 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
15 CoreFoundation 0x000000010124722c __CFRunLoopDoSources0 + 556
16 CoreFoundation 0x00000001012466e3 __CFRunLoopRun + 867
17 CoreFoundation 0x00000001012460f8 CFRunLoopRunSpecific + 488
18 GraphicsServices 0x000000010496dad2 GSEventRunModal + 161
19 UIKit 0x0000000101d94f09 UIApplicationMain + 171
20 TouchLogin 0x0000000100fa6cc2 main + 114
21 libdyld.dylib 0x000000010437192d start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)

segmented control - unrecognized selector sent to instance

I want to use sender to get the value from segmented control, but I am getting the unrecognized selector sent to instance error. The segmented control was added within a view. I've tried removing the semicolon and/or sender and none of the prior posts I've found seem to help. Any ideas?
Swift Code
var segCntrl = UISegmentedControl(items: ["Yes","No"])
segCntrl.tag = 100
segCntrl.center = CGPointMake(qView.bounds.width/2, qView.bounds.minY+40)
self.qView.addSubview(segCntrl)
func segmentorSwitch(sender: AnyObject) {
if(sender.selectedSegmentIndex == 1) {
println("Yes selected")
}
else if(sender.selectedSegmentIndex == 2) {
println("No selected")
}
}
segCntrl.addTarget(self, action: "segmentorSwitch:", forControlEvents: UIControlEvents.ValueChanged)
Error code:
2015-07-07 11:46:24.482 myApp [75641:1855377] -[[myApp.SegViewControllerr segmentorSwitch:]: unrecognized selector sent to instance 0x7fbb0a43b450
2015-07-07 11:46:24.489 myApp[75641:1855377] * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[myApp.SegViewController segmentorSwitch:]: unrecognized selector sent to instance 0x7fbb0a43b450'
* First throw call stack:
(
0 CoreFoundation 0x00000001060dcc65 exceptionPreprocess + 165
1 libobjc.A.dylib 0x000000010838abb7 objc_exception_throw + 45
2 CoreFoundation 0x00000001060e40ad -[NSObject(NSObject) doesNotRecognizeSelector:] + 205
3 CoreFoundation 0x000000010603a13c ___forwarding_ + 988
4 CoreFoundation 0x0000000106039cd8 _CF_forwarding_prep_0 + 120
5 UIKit 0x00000001070bfd62 -[UIApplication sendAction:to:from:forEvent:] + 75
6 UIKit 0x00000001071d150a -[UIControl _sendActionsForEvents:withEvent:] + 467
7 UIKit 0x000000010724dfba -[UISegmentedControl _setSelectedSegmentIndex:notify:animate:] + 570
8 UIKit 0x000000010724ffbf -[UISegmentedControl touchesEnded:withEvent:] + 143
9 UIKit 0x000000010710c958 -[UIWindow _sendTouchesForEvent:] + 735
10 UIKit 0x000000010710d282 -[UIWindow sendEvent:] + 682
11 UIKit 0x00000001070d3541 -[UIApplication sendEvent:] + 246
12 UIKit 0x00000001070e0cdc _UIApplicationHandleEventFromQueueEvent + 18265
13 UIKit 0x00000001070bb59c _UIApplicationHandleEventQueue + 2066
14 CoreFoundation 0x0000000106010431 CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION + 17
15 CoreFoundation 0x00000001060062fd __CFRunLoopDoSources0 + 269
16 CoreFoundation 0x0000000106005934 __CFRunLoopRun + 868
17 CoreFoundation 0x0000000106005366 CFRunLoopRunSpecific + 470
18 GraphicsServices 0x000000010cc5ba3e GSEventRunModal + 161
19 UIKit 0x00000001070be8c0 UIApplicationMain + 1282
20 myApp 0x0000000104d9a0c7 main + 135
21 libdyld.dylib 0x0000000109458145 start + 1
22 ??? 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
Looks like segmentorSwitch: is implemented inside another method. Define it outside the method in which your code is contained, and this should be fixed.

NSURL URLWithString gives error: unrecognized selector sent to instance

In my new app I have to external links. One in the view that only is shown the very first time the app is started and one in tab3. The link in tab3 is working, but the link in the initial screen is giving a crash, while exactly the same code is used.
Code for ViewController.h
- (IBAction)findAllyId;
Code for ViewController.m
- (IBAction)findAllyId {
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:#"http://youtu.be/H_AguOLEHW8"]];
}
Error log after pressing the Button that is linked to this findAllyId
2015-03-13 19:03:30.666 Friend codes for Kingdom Age[89581:40810062] -[ViewController findAllyId]: unrecognized selector sent to instance 0x7facaa694530
2015-03-13 19:03:30.674 Friend codes for Kingdom Age[89581:40810062] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[ViewController findAllyId]: unrecognized selector sent to instance 0x7facaa694530'
*** First throw call stack:
(
0 CoreFoundation 0x000000010e141a75 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x000000010dddabb7 objc_exception_throw + 45
2 CoreFoundation 0x000000010e148d1d -[NSObject(NSObject) doesNotRecognizeSelector:] + 205
3 CoreFoundation 0x000000010e0a09dc ___forwarding___ + 988
4 CoreFoundation 0x000000010e0a0578 _CF_forwarding_prep_0 + 120
5 UIKit 0x000000010c430a22 -[UIApplication sendAction:to:from:forEvent:] + 75
6 UIKit 0x000000010c537e50 -[UIControl _sendActionsForEvents:withEvent:] + 467
7 UIKit 0x000000010c53721f -[UIControl touchesEnded:withEvent:] + 522
8 UIKit 0x000000010c476b68 -[UIWindow _sendTouchesForEvent:] + 735
9 UIKit 0x000000010c477493 -[UIWindow sendEvent:] + 683
10 UIKit 0x000000010c443fb1 -[UIApplication sendEvent:] + 246
11 UIKit 0x000000010c451227 _UIApplicationHandleEventFromQueueEvent + 17700
12 UIKit 0x000000010c42c23c _UIApplicationHandleEventQueue + 2066
13 CoreFoundation 0x000000010e076c91 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
14 CoreFoundation 0x000000010e06cb5d __CFRunLoopDoSources0 + 269
15 CoreFoundation 0x000000010e06c194 __CFRunLoopRun + 868
16 CoreFoundation 0x000000010e06bbc6 CFRunLoopRunSpecific + 470
17 GraphicsServices 0x000000010fc5aa58 GSEventRunModal + 161
18 UIKit 0x000000010c42f580 UIApplicationMain + 1282
19 Friend codes for Kingdom Age 0x000000010b9f9d83 main + 115
20 libdyld.dylib 0x000000010e6af145 start + 1
21 ??? 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
Again, exactly the same code (with a different URL) is working in another screen of the app, with a click on a button.

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.

Unrecognized selector sent to instance, Storyboard bug after connecting a button to view controller

I was messing with my storyboard with no code involved and got this error after I connected "Terms of use" button to a view controller. It was working fine before this action.
-I created and connected a class to Terms of Use View Controller
-I used action push segue to connect
2014-01-22 17:26:45.434 Project[1162:a0b] -[AboutViewController termsOfUseButton:]: unrecognized selector sent to instance 0x8c89d40
2014-01-22 17:26:45.437 Project[1162:a0b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[AboutViewController termsOfUseButton:]: unrecognized selector sent to instance 0x8c89d40'
*** First throw call stack:
(
0 CoreFoundation 0x0173b5e4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x014be8b6 objc_exception_throw + 44
2 CoreFoundation 0x017d8903 -[NSObject(NSObject) doesNotRecognizeSelector:] + 275
3 CoreFoundation 0x0172b90b ___forwarding___ + 1019
4 CoreFoundation 0x0172b4ee _CF_forwarding_prep_0 + 14
5 libobjc.A.dylib 0x014d0874 -[NSObject performSelector:withObject:withObject:] + 77
6 UIKit 0x0022e0c2 -[UIApplication sendAction:to:from:forEvent:] + 108
7 UIKit 0x0022e04e -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 61
8 UIKit 0x003260c1 -[UIControl sendAction:to:forEvent:] + 66
9 UIKit 0x00326484 -[UIControl _sendActionsForEvents:withEvent:] + 577
10 UIKit 0x00325733 -[UIControl touchesEnded:withEvent:] + 641
11 UIKit 0x0026b51d -[UIWindow _sendTouchesForEvent:] + 852
12 UIKit 0x0026c184 -[UIWindow sendEvent:] + 1232
13 UIKit 0x0023fe86 -[UIApplication sendEvent:] + 242
14 UIKit 0x0022a18f _UIApplicationHandleEventQueue + 11421
15 CoreFoundation 0x016c483f __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15
16 CoreFoundation 0x016c41cb __CFRunLoopDoSources0 + 235
17 CoreFoundation 0x016e129e __CFRunLoopRun + 910
18 CoreFoundation 0x016e0ac3 CFRunLoopRunSpecific + 467
19 CoreFoundation 0x016e08db CFRunLoopRunInMode + 123
20 GraphicsServices 0x036909e2 GSEventRunModal + 192
21 GraphicsServices 0x03690809 GSEventRun + 104
22 UIKit 0x0022cd3b UIApplicationMain + 1225
23 Project 0x00003a9d main + 141
24 libdyld.dylib 0x01d77725 start + 0
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
(Lame but I found the solution after I finished writing the question)
The reason for this error is I created an IBAction-UIButton method on touch up inside.
I deleted that code and hoped the traces were deleted.
It seems it wasnt, I had to unconnect the touch up inside by clicking the X in red squared spot.
I would try recreating the button and the segue, maybe you changed the IBOutlet name by accident or any other thing.
GL HF

Resources