Swift ViewController textFieldCancel:]: unrecognized selector sent to instance during segue [duplicate] - swift

This question already has answers here:
"Unrecognized selector sent to instance" error
(3 answers)
Closed 7 years ago.
I've run into an annoying issue when trying to segue to a Pages View Controller from my initial UIViewController. My initial UIViewController, among other things, includes a UITextField. Everytime I attempt to segue out of my initial UIViewController after I've used the UITextField at all, the app crashes with the error below. If I don't interact with the UITextField I seem to be able to use segues at will. From reading other posts I'm lead to believe there are some resources being used by the UITextField that I'm not properly releasing, but after trying numerous longshot attempts at fixing it, I'm left out of ideas/knowledge.
Error Message:
2015-05-22 20:10:13.961 checkdgt[7503:506991] -[checkdgt.ViewController textFieldCancel:]: unrecognized selector sent to instance 0x7f8750826e00
2015-05-22 20:10:14.033 checkdgt[7503:506991] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[checkdgt.ViewController textFieldCancel:]: unrecognized selector sent to instance 0x7f8750826e00'
*** First throw call stack:
(
0 CoreFoundation 0x000000010bd00c65 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x000000010df63bb7 objc_exception_throw + 45
2 CoreFoundation 0x000000010bd080ad -[NSObject(NSObject) doesNotRecognizeSelector:] + 205
3 CoreFoundation 0x000000010bc5e13c ___forwarding___ + 988
4 CoreFoundation 0x000000010bc5dcd8 _CF_forwarding_prep_0 + 120
5 UIKit 0x000000010cc5dda2 -[UIApplication sendAction:to:from:forEvent:] + 75
6 UIKit 0x000000010cd6f54a -[UIControl _sendActionsForEvents:withEvent:] + 467
7 UIKit 0x000000010cd6e09a -[UIControl cancelTouchTracking] + 44
8 UIKit 0x000000010cd6eadd -[UIControl _didMoveFromWindow:toWindow:] + 89
9 UIKit 0x000000010ccd774a -[UIView(Internal) _didMoveFromWindow:toWindow:] + 698
10 UIKit 0x000000010ccd774a -[UIView(Internal) _didMoveFromWindow:toWindow:] + 698
11 UIKit 0x000000010cccfecf __45-[UIView(Hierarchy) _postMovedFromSuperview:]_block_invoke + 125
12 UIKit 0x000000010cccfe43 -[UIView(Hierarchy) _postMovedFromSuperview:] + 437
13 UIKit 0x000000010cccdfa3 -[UIView(Hierarchy) removeFromSuperview] + 479
14 UIKit 0x000000010cd6c4dc __71-[UIPresentationController _initViewHierarchyForPresentationSuperview:]_block_invoke504 + 657
15 UIKit 0x000000010cd684f2 -[UIPresentationController transitionDidFinish:] + 87
16 UIKit 0x000000010d31a2ed -[_UIFullscreenPresentationController transitionDidFinish:] + 70
17 UIKit 0x000000010cd6ab7c __56-[UIPresentationController runTransitionForCurrentState]_block_invoke_2 + 133
18 UIKit 0x000000010d3a97c0 -[_UIViewControllerTransitionContext completeTransition:] + 110
19 UIKit 0x000000010cd65be3 -[UITransitionView _didCompleteTransition:] + 1120
20 UIKit 0x000000010ccbc136 -[UIViewAnimationState sendDelegateAnimationDidStop:finished:] + 209
21 UIKit 0x000000010ccbc46c -[UIViewAnimationState animationDidStop:finished:] + 76
22 QuartzCore 0x000000010ca43882 _ZN2CA5Layer23run_animation_callbacksEPv + 308
23 libdispatch.dylib 0x000000010e693614 _dispatch_client_callout + 8
24 libdispatch.dylib 0x000000010e67ba1c _dispatch_main_queue_callback_4CF + 1664
25 CoreFoundation 0x000000010bc681f9 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
26 CoreFoundation 0x000000010bc29dcb __CFRunLoopRun + 2043
27 CoreFoundation 0x000000010bc29366 CFRunLoopRunSpecific + 470
28 GraphicsServices 0x000000010f88ba3e GSEventRunModal + 161
29 UIKit 0x000000010cc5c900 UIApplicationMain + 1282
30 checkdgt 0x000000010b1f3f87 main + 135
31 libdyld.dylib 0x000000010e6c7145 start + 1
32 ??? 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
Last bit of code before the segue is called:
#IBAction func learnButtonPressed(sender: UIButton) {
view.endEditing(true)
textInputFieldOutlet.resignFirstResponder()
textFieldShouldEndEditing(textInputFieldOutlet)
performSegueWithIdentifier("LearnPagesSegue", sender: nil)
}
I can't find any methods or objects in my code named -textFieldCancel, and the only other UITextField I can think of would be in the included CardIO library, which doesn't seem to be the suspect.
I'm using Xcode 6.3.2 and the latest version of Swift.
Any help or gentle nudges are appreciated.
Thanks!

Check that there isn't an old connection from your button by right clicking on it in the storyboard and examining the outlets in the list. You may have an old connection that you forgot to eliminate.

Related

App crashes when table menu item selected in swift

The app crashes in simulator when one item is pressed on the slide out menu (created with table view), I've tried deleting connections between UI and IB and remaking them incase this is the issue, but it hasn't solved it.
This is the error code that comes out:
View Controller is : <AKSwiftSlideMenu.HomeVC: 0x7fa6c5e05b90>
Calculate your own repayment
2017-02-08 17:36:13.782 AKSwiftSlideMenu[37086:3161182] Unknown class TrackerVC in Interface Builder file.
2017-02-08 17:36:13.801 AKSwiftSlideMenu[37086:3161182] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<UIViewController 0x7fa6c5d1f920> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key AnnualInterestInput.'
*** First throw call stack:
(
0 CoreFoundation 0x000000010a9a0d4b __exceptionPreprocess + 171
1 libobjc.A.dylib 0x000000010a40221e objc_exception_throw + 48
2 CoreFoundation 0x000000010a9a0c99 -[NSException raise] + 9
3 Foundation 0x0000000109f109df -[NSObject(NSKeyValueCoding) setValue:forKey:] + 291
4 UIKit 0x000000010af5f293 -[UIViewController setValue:forKey:] + 88
5 UIKit 0x000000010b1d379e -[UIRuntimeOutletConnection connect] + 109
6 CoreFoundation 0x000000010a9459e0 -[NSArray makeObjectsPerformSelector:] + 256
7 UIKit 0x000000010b1d2122 -[UINib instantiateWithOwner:options:] + 1867
8 UIKit 0x000000010af659c5 -[UIViewController _loadViewFromNibNamed:bundle:] + 386
9 UIKit 0x000000010af662e7 -[UIViewController loadView] + 177
10 UIKit 0x000000010af6661c -[UIViewController loadViewIfRequired] + 201
11 UIKit 0x000000010af6d062 -[UIViewController __viewWillAppear:] + 118
12 UIKit 0x000000010af981d3 -[UINavigationController _startCustomTransition:] + 1290
13 UIKit 0x000000010afa8e48 -[UINavigationController _startDeferredTransitionIfNeeded:] + 697
14 UIKit 0x000000010afa9fdb -[UINavigationController __viewWillLayoutSubviews] + 58
15 UIKit 0x000000010b1a0dd7 -[UILayoutContainerView layoutSubviews] + 223
16 UIKit 0x000000010ae89ab8 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 1237
17 QuartzCore 0x000000010f85fbf8 -[CALayer layoutSublayers] + 146
18 QuartzCore 0x000000010f853440 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 366
19 QuartzCore 0x000000010f8532be _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 24
20 QuartzCore 0x000000010f7e1318 _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 280
21 QuartzCore 0x000000010f80e3ff _ZN2CA11Transaction6commitEv + 475
22 UIKit 0x000000010adef7f0 _afterCACommitHandler + 346
23 CoreFoundation 0x000000010a945267 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 23
24 CoreFoundation 0x000000010a9451d7 __CFRunLoopDoObservers + 391
25 CoreFoundation 0x000000010a929f8e __CFRunLoopRun + 1198
26 CoreFoundation 0x000000010a929884 CFRunLoopRunSpecific + 420
27 GraphicsServices 0x000000010f02fa6f GSEventRunModal + 161
28 UIKit 0x000000010adc4c68 UIApplicationMain + 159
29 AKSwiftSlideMenu 0x0000000109e0401f main + 111
30 libdyld.dylib 0x000000010e09f68d start + 1
31 ??? 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
According to the error, it most probably is that one of your views is connected to an outlet named AnnualInterestInput that was deleted from the class.
If by deleting all the outlets and reconnecting them to the view controller didn't work it out, then it may be due to a wrong class in the xib.
This means that you have set a wrong class in the xib or storyboard and it's not able to found the key. If the class is still correct, check if the module is correct!
This line is what gives me a hint that this could be the problem:
2017-02-08 17:36:13.782 AKSwiftSlideMenu[37086:3161182] Unknown class TrackerVC in Interface Builder file.

Custom segue and custom unwind segue in swift

I have implemented custom segue and custom unwind segue in a sample app using swift. custom segue is working properly but custom unwind segue give the following error:
2015-06-22 21:05:58.929 Test_Segue[7162:336393] -[__NSSetM perform:]: unrecognized selector sent to instance 0x7ffc89c190c0
2015-06-22 21:05:58.933 Test_Segue[7162:336393] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSSetM perform:]: unrecognized selector sent to instance 0x7ffc89c190c0'
*** First throw call stack:
(
0 CoreFoundation 0x000000010d27bc65 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x000000010b228bb7 objc_exception_throw + 45
2 CoreFoundation 0x000000010d2830ad -[NSObject(NSObject) doesNotRecognizeSelector:] + 205
3 CoreFoundation 0x000000010d1d913c ___forwarding___ + 988
4 CoreFoundation 0x000000010d1d8cd8 _CF_forwarding_prep_0 + 120
5 UIKit 0x000000010b46bda2 -[UIApplication sendAction:to:from:forEvent:] + 75
6 UIKit 0x000000010b57d54a -[UIControl _sendActionsForEvents:withEvent:] + 467
7 UIKit 0x000000010b57c919 -[UIControl touchesEnded:withEvent:] + 522
8 UIKit 0x000000010b4b8998 -[UIWindow _sendTouchesForEvent:] + 735
9 UIKit 0x000000010b4b92c2 -[UIWindow sendEvent:] + 682
10 UIKit 0x000000010b47f581 -[UIApplication sendEvent:] + 246
11 UIKit 0x000000010b48cd1c _UIApplicationHandleEventFromQueueEvent + 18265
12 UIKit 0x000000010b4675dc _UIApplicationHandleEventQueue + 2066
13 CoreFoundation 0x000000010d1af431 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
14 CoreFoundation 0x000000010d1a52fd __CFRunLoopDoSources0 + 269
15 CoreFoundation 0x000000010d1a4934 __CFRunLoopRun + 868
16 CoreFoundation 0x000000010d1a4366 CFRunLoopRunSpecific + 470
17 GraphicsServices 0x000000010eeb4a3e GSEventRunModal + 161
18 UIKit 0x000000010b46a900 UIApplicationMain + 1282
19 Test_Segue 0x000000010acd8e87 main + 135
20 libdyld.dylib 0x000000010df33145 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
The source code of this sample app is uploaded on github, the link is as follows:
source code
I implement segue and add the animation and it works.

popToViewController failed to pop to view error

I am using the following code:
#IBAction func popToRoot(sender:UIBarButtonItem){
navigationController.popToViewController(foodforteethViewController(), animated: false)
}
This function is linked with a custom back button and the h file is linked in the objective-c/swift bridging file. The issue with this is that I get an error as below:
2014-07-19 23:35:40.842 FoodForTeeth[9040:238499] * Assertion failure in -[UINavigationController popToViewController:transition:], /SourceCache/UIKit_Sim/UIKit-3232.3/UINavigationController.m:5345
2014-07-19 23:35:40.845 FoodForTeeth[9040:238499] * Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Failed to get popped view controller.'
* First throw call stack:
(
0 CoreFoundation 0x00000001023ec995 exceptionPreprocess + 165
1 libobjc.A.dylib 0x000000010209b9a3 objc_exception_throw + 45
2 CoreFoundation 0x00000001023ec7fa +[NSException raise:format:arguments:] + 106
3 Foundation 0x0000000101cc637f -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 195
4 UIKit 0x0000000100b456b6 -[UINavigationController popToViewController:transition:] + 762
5 FoodForTeeth 0x00000001000272fe _TFC12FoodForTeeth9dietDiary9popToRootfS0_FCSo15UIBarButtonItemT_ + 302
6 FoodForTeeth 0x00000001000274f2 _TToFC12FoodForTeeth9dietDiary9popToRootfS0_FCSo15UIBarButtonItemT_ + 66
7 UIKit 0x00000001009f76b6 -[UIApplication sendAction:to:from:forEvent:] + 75
8 UIKit 0x00000001009f76b6 -[UIApplication sendAction:to:from:forEvent:] + 75
9 UIKit 0x0000000100af91c0 -[UIControl _sendActionsForEvents:withEvent:] + 467
10 UIKit 0x0000000100af858f -[UIControl touchesEnded:withEvent:] + 522
11 UIKit 0x0000000100a3c3b8 -[UIWindow _sendTouchesForEvent:] + 735
12 UIKit 0x0000000100a3cce3 -[UIWindow sendEvent:] + 683
13 UIKit 0x0000000100a0a1a1 -[UIApplication sendEvent:] + 246
14 UIKit 0x0000000100a1707a _UIApplicationHandleEventFromQueueEvent + 17591
15 UIKit 0x00000001009f3269 _UIApplicationHandleEventQueue + 1967
16 CoreFoundation 0x0000000102322a31 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION + 17
17 CoreFoundation 0x000000010231826d __CFRunLoopDoSources0 + 269
18 CoreFoundation 0x00000001023178a4 __CFRunLoopRun + 868
19 CoreFoundation 0x00000001023172d6 CFRunLoopRunSpecific + 470
20 GraphicsServices 0x0000000105475bbc GSEventRunModal + 161
21 UIKit 0x00000001009f6288 UIApplicationMain + 1282
22 FoodForTeeth 0x0000000100054db3 main + 115
23 libdyld.dylib 0x0000000102b45145 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
What's going wrong?
you can not pop a view controller which is not in NavigationController stack.You should pop like this
if you want pop to rootViewController than there is direct method use this
#IBAction func popToRoot(sender:UIBarButtonItem){
self.navigationController.popToRootViewControllerAnimated(false)
}
Another way to go back to a specific view controller would be to use unwind segues:
What are Unwind segues for and how do you use them?

Unrecognized Selector with OHGridView

I downloaded the OHGridView hoping that it was the answer to all my problems.
https://github.com/AliSoftware/OHGridView
I did all that it said to do (add the class files, add the code, and change a few other things).
I went to build it and it crashed. I realized the lines of code why it was crashing:
((OHGridView *)self.view).rowHeight = 100;
((OHGridView *)self.view).columnsCount = 2;
Error from Console:
`-[UIView setRowHeight:]: unrecognized selector sent to instance 0x4b55110
2011-02-20 09:01:16.906 TableView[14358:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIView setRowHeight:]: unrecognized selector sent to instance 0x4b55110'
*** Call stack at first throw:
(
0 CoreFoundation 0x00e4dbe9 __exceptionPreprocess + 185
1 libobjc.A.dylib 0x00fa25c2 objc_exception_throw + 47
2 CoreFoundation 0x00e4f6fb -[NSObject(NSObject) doesNotRecognizeSelector:] + 187
3 CoreFoundation 0x00dbf366 ___forwarding___ + 966
4 CoreFoundation 0x00dbef22 _CF_forwarding_prep_0 + 50
5 TableView 0x00004232 -[DetailViewController viewDidLoad] + 831
6 UIKit 0x0037165e -[UIViewController view] + 179
7 UIKit 0x0036fa57 -[UIViewController contentScrollView] + 42
8 UIKit 0x00380201 -[UINavigationController _computeAndApplyScrollContentInsetDeltaForViewController:] + 48
9 UIKit 0x0037e831 -[UINavigationController _layoutViewController:] + 43
10 UIKit 0x0037fa86 -[UINavigationController _startTransition:fromViewController:toViewController:] + 326
11 UIKit 0x0037a606 -[UINavigationController _startDeferredTransitionIfNeeded] + 266
12 UIKit 0x0038183e -[UINavigationController pushViewController:transition:forceImmediate:] + 932
13 UIKit 0x0037a4a0 -[UINavigationController pushViewController:animated:] + 62
14 TableView 0x00002e4f -[RootViewController tableView:didSelectRowAtIndexPath:] + 681
15 UIKit 0x00339794 -[UITableView _selectRowAtIndexPath:animated:scrollPosition:notifyDelegate:] + 1140
16 UIKit 0x0032fd50 -[UITableView _userSelectRowAtPendingSelectionIndexPath:] + 219
17 Foundation 0x000427f6 __NSFireDelayedPerform + 441
18 CoreFoundation 0x00e2efe3 __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 19
19 CoreFoundation 0x00e30594 __CFRunLoopDoTimer + 1220
20 CoreFoundation 0x00d8ccc9 __CFRunLoopRun + 1817
21 CoreFoundation 0x00d8c240 CFRunLoopRunSpecific + 208
22 CoreFoundation 0x00d8c161 CFRunLoopRunInMode + 97
23 GraphicsServices 0x016ef268 GSEventRunModal + 217
24 GraphicsServices 0x016ef32d GSEventRun + 115
25 UIKit 0x002d242e UIApplicationMain + 1160
26 TableView 0x00001abc main + 102
27 TableView 0x00001a4d start + 53
)
terminate called after throwing an instance of 'NSException`
I removed them and it loaded fine but I didn't see any content.
Please help,
thanks.
I did a clone of the repository just now and then did a build and run of his example project without making any changes to the code. It ran without any warnings or errors.
You'll need to check your code wherever you made changes.
update after your comment
Unrecognized Selector often means that you have a capitalization error or that your code isn't the kind of object that you think it is.
For example: I can get almost the same error that you get if I try to call the setRowHeight: directly against a OHGridView object instead of the view property of the object, like this
((OHGridView*)self).rowHeight = 100;
((OHGridView*)self).columnsCount = 2;
So, I would check your code to make sure that your object is an OHGridView and that you are setting the rowHeight property of the view of the OHGridView.

Assertion Failure

I am developing an iPad application with SDK4.2. I have a very strange error when touching any textField in my application. The first time I touch, the keyboard is shown, but when a second touch is done in the object I obtain following trace.
And it occurs also in any TextField shown in a HTML page with a UIWebView object.
Any ideas?
I am really confused with this.. Thanks in advance!
2010-12-17 11:53:11.697 BancoPopular[48914:207] *** Assertion failure in -[UIButtonLabel setTextColor:], /SourceCache/UIKit_Sim/UIKit-1447.6.4/UILabel.m:314
2010-12-17 11:53:11.699 BancoPopular[48914:207] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid parameter not satisfying: color'
*** Call stack at first throw:
(
0 CoreFoundation 0x01730be9 __exceptionPreprocess + 185
1 libobjc.A.dylib 0x018855c2 objc_exception_throw + 47
2 CoreFoundation 0x016e9628 +[NSException raise:format:arguments:] + 136
3 Foundation 0x0013947b -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 116
4 UIKit 0x0045d1dc -[UILabel setTextColor:] + 164
5 UIKit 0x0052177b -[UIButton layoutSubviews] + 1337
6 UIKit 0x005f3420 -[UICalloutBarButton layoutSubviews] + 54
7 QuartzCore 0x011a4451 -[CALayer layoutSublayers] + 181
8 QuartzCore 0x011a417c CALayerLayoutIfNeeded + 220
9 QuartzCore 0x011a4088 -[CALayer layoutIfNeeded] + 111
10 UIKit 0x0051f2ff -[UIButton titleLabel] + 81
11 UIKit 0x005f81d1 -[UICalloutBarButton setContentScale:] + 141
12 UIKit 0x005f6c5d -[UICalloutBar _updateVisibleItems] + 2240
13 UIKit 0x005f2970 -[UICalloutBar appear] + 211
14 UIKit 0x005eaaa9 -[UITextSelectionView showCommandsWithReplacements:] + 291
15 Foundation 0x000bd7f6 __NSFireDelayedPerform + 441
16 CoreFoundation 0x01711fe3 __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 19
17 CoreFoundation 0x01713594 __CFRunLoopDoTimer + 1220
18 CoreFoundation 0x0166fcc9 __CFRunLoopRun + 1817
19 CoreFoundation 0x0166f240 CFRunLoopRunSpecific + 208
20 CoreFoundation 0x0166f161 CFRunLoopRunInMode + 97
21 GraphicsServices 0x01e25268 GSEventRunModal + 217
22 GraphicsServices 0x01e2532d GSEventRun + 115
23 UIKit 0x0034d42e UIApplicationMain + 1160
24 BancoPopular 0x0000292e main + 84
25 BancoPopular 0x000028d1 start + 53
26 ??? 0x00000001 0x0 + 1
)
terminate called after throwing an instance of 'NSException'
Look carefully what exception was about. It said "reason: 'Invalid parameter not satisfying: color'", somewhere in your code, you provide wrong parameter that is supposed to be valid colors. Apparently, it seems like you use UIButton with label and set its color but not valid.
My guess is that you have some object going away somewhere, and that object contains the "color" value.
Most likely you received an autoreleased value from some call and did not retain it, so it went "poof" when the UI came up for air.