UINavigation is pushing the same view controller twice error - ios

I am getting the following error when pushing a view controller onto the stack:
Thread 1: Exception: "<UINavigationController: 0x7f9345817a00> is pushing the same view controller instance (<xxxx.HelpViewController: 0x7f9346143390>) more than once which is not supported and is most likely an error in the application : com.xxx.xxx1"
I am calling the view controller from a table view controller with the following code:
let myVC = self.storyboard?.instantiateViewController(identifier: "HelpViewController") as! HelpViewController
// pass any parms here
myVC.stringPassed = label!.text!
navigationController?.pushViewController(myVC, animated: true)
self.navigationController!.pushViewController(myVC, animated: false)
I have only one copy of the view controller and this is the first time I am pushing this view onto the stack.
Any help would be appreciated.
Here is the log:
2020-08-13 17:42:45.289742-0500 NCLEX[29470:2944371] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '<UINavigationController: 0x7f94e980ce00> is pushing the same view controller instance (<xxx.HelpViewController: 0x7f94e54634a0>) more than once which is not supported and is most likely an error in the application : com.xxx.xxx'
*** First throw call stack:
(
0 CoreFoundation 0x00007fff23e3de6e __exceptionPreprocess + 350
1 libobjc.A.dylib 0x00007fff512539b2 objc_exception_throw + 48
2 UIKitCore 0x00007fff48be2df6 -[UINavigationController pushViewController:transition:forceImmediate:] + 451
3 UIKitCore 0x00007fff48be2a9f -[UINavigationController pushViewController:animated:] + 669
4 UIKitCore 0x00007fff48ca880d -[_UIViewControllerTransitionCoordinator _applyBlocks:releaseBlocks:] + 294
5 UIKitCore 0x00007fff48ca495b -[_UIViewControllerTransitionContext _runAlongsideCompletions] + 126
6 UIKitCore 0x00007fff48ca46cf -[_UIViewControllerTransitionContext completeTransition:] + 106
7 UIKitCore 0x00007fff48cb6e1f __53-[_UINavigationParallaxTransition animateTransition:]_block_invoke.158 + 806
8 UIKitCore 0x00007fff4982093c -[UIViewAnimationBlockDelegate _didEndBlockAnimation:finished:context:] + 671
9 UIKitCore 0x00007fff497f15c9 -[UIViewAnimationState sendDelegateAnimationDidStop:finished:] + 220
10 UIKitCore 0x00007fff497f1bc0 -[UIViewAnimationState animationDidStop:finished:] + 276
11 UIKitCore 0x00007fff497f1d46 -[UIViewAnimationState animationDidStop:finished:] + 666
12 QuartzCore 0x00007fff2b4fbadc _ZN2CA5Layer23run_animation_callbacksEPv + 306
13 libdispatch.dylib 0x0000000110475e8e _dispatch_client_callout + 8
14 libdispatch.dylib 0x0000000110483d97 _dispatch_main_queue_callback_4CF + 1149
15 CoreFoundation 0x00007fff23da1869 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
16 CoreFoundation 0x00007fff23d9c3b9 __CFRunLoopRun + 2041
17 CoreFoundation 0x00007fff23d9b8a4 CFRunLoopRunSpecific + 404
18 GraphicsServices 0x00007fff38c39bbe GSEventRunModal + 139
19 UIKitCore 0x00007fff49325968 UIApplicationMain + 1605
20 NCLEX 0x000000010f37007b main + 75
21 libdyld.dylib 0x00007fff520ce1fd start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException

You need to comment 1 line from these 2 mostly the second 1 if you don't need an animation
navigationController?.pushViewController(myVC, animated: true)
self.navigationController!.pushViewController(myVC, animated: false)
as they do the same thing which is pushing the same vc twice that causes the crash

Related

App crashes when keyboard is numberPad, phonePad or decimalPad (iOS 12.2, Xcode 10.2)

My app has suddenly started crashing when keyboard type is numberPad or phonePad. The crash happen in simulator and device both. I am setting keyboard type by below code.
self.textFieldMobileNumber.keyboardType = .numberPad
Default keyboard just works fine. The crash log is blow
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSSetM addObject:]: object cannot be nil'
*** First throw call stack:
(
0 CoreFoundation 0x0000000112d0f6fb __exceptionPreprocess + 331
1 libobjc.A.dylib 0x0000000112051ac5 objc_exception_throw + 48
2 CoreFoundation 0x0000000112c5dddc _CFThrowFormattedException + 194
3 CoreFoundation 0x0000000112c81601 -[__NSSetM addObject:] + 817
4 UIKitCore 0x000000011ca49f8f +[UIKeyboardImpl uniqueNumberPadInputModesFromInputModes:forKeyboardType:] + 1257
5 UIKitCore 0x000000011ca4998f -[UIKeyboardImpl desirableInputModesWithExtensions:] + 1446
6 UIKitCore 0x000000011ca4a0cf -[UIKeyboardImpl recomputeActiveInputModesWithExtensions:] + 54
7 UIKitCore 0x000000011ca3b158 -[UIKeyboardImpl setDelegate:force:] + 3343
8 UIKitCore 0x000000011ca8db1e -[UIPeripheralHost(UIKitInternal) _reloadInputViewsForResponder:] + 1506
9 UIKitCore 0x000000011cc4d417 -[UIResponder(UIResponderInputViewAdditions) reloadInputViews] + 81
10 UIKitCore 0x000000011cc4916a -[UIResponder becomeFirstResponder] + 865
11 UIKitCore 0x000000011d0d4fb8 -[UIView(Hierarchy) becomeFirstResponder] + 145
12 UIKitCore 0x000000011cf269ec -[UITextField becomeFirstResponder] + 237
13 UIKitCore 0x000000011cee67a5 -[UITextInteractionAssistant(UITextInteractionAssistant_Internal) setFirstResponderIfNecessary] + 208
14 UIKitCore 0x000000011ced3853 -[UITextSelectionInteraction oneFingerTap:] + 3851
15 UIKitCore 0x000000011c80714d -[UIGestureRecognizerTarget _sendActionWithGestureRecognizer:] + 57
16 UIKitCore 0x000000011c80fc69 _UIGestureRecognizerSendTargetActions + 109
17 UIKitCore 0x000000011c80d5ba _UIGestureRecognizerSendActions + 311
18 UIKitCore 0x000000011c80c897 -[UIGestureRecognizer _updateGestureWithEvent:buttonEvent:] + 966
19 UIKitCore 0x000000011c7fec4e _UIGestureEnvironmentUpdate + 2820
20 UIKitCore 0x000000011c7fe108 -[UIGestureEnvironment _deliverEvent:toGestureRecognizers:usingBlock:] + 478
21 UIKitCore 0x000000011c7fde96 -[UIGestureEnvironment _updateForEvent:window:] + 200
22 UIKitCore 0x000000011cc595bc -[UIWindow sendEvent:] + 4057
23 UIKitCore 0x000000011cc37d16 -[UIApplication sendEvent:] + 356
24 UIKitCore 0x000000011cd08293 __dispatchPreprocessedEventFromEventQueue + 3232
25 UIKitCore 0x000000011cd0abb9 __handleEventQueueInternal + 5911
26 CoreFoundation 0x0000000112c76be1 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
27 CoreFoundation 0x0000000112c76463 __CFRunLoopDoSources0 + 243
28 CoreFoundation 0x0000000112c70b1f __CFRunLoopRun + 1231
29 CoreFoundation 0x0000000112c70302 CFRunLoopRunSpecific + 626
30 GraphicsServices 0x00000001171ab2fe GSEventRunModal + 65
31 UIKitCore 0x000000011cc1dba2 UIApplicationMain + 140
32 IMRide 0x000000010b39beb8 main + 72
33 libdyld.dylib 0x000000011560a541 start + 1
34 ??? 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
I have searched all over the internet and tried many solution from my side but the issue did not fix.
Edit
When I set default keyboard. It shows (null) for number keyboard, switching to that does not crash but when set .numberPad keyboard it starts crashing.
Check the image below for the reference
Finally I found the issue. I had overridden a method of NumberFormatter which caused the crash while showing numberPad keyboard.
Below is the method that I override which should not have been done, or done in some other way.
extension NumberFormatter {
open override func string(for obj: Any?) -> String? {
if condition {
return <some value based on condition>
}
return nil
}
}
Returning nil caused the crash. Also if you return something else rather then the obj it will print the same in keyboard keys.

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.

paypal SDK integration objective c

I'm trying to integrate Paypal to my objective c project.
After the Paypal login screen appears and i enter my login data and login success and this view pops to the previous view which should display the logged client data the application crashes giving me the following error
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSPlaceholderDictionary initWithObjects:forKeys:count:]: attempt to insert nil object from objects[0]'
*** First throw call stack:
(
0 CoreFoundation 0x0000000113defd85 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x00000001137f7deb objc_exception_throw + 48
2 CoreFoundation 0x0000000113cec23e -[__NSPlaceholderDictionary initWithObjects:forKeys:count:] + 318
3 CoreFoundation 0x0000000113cfe5bb +[NSDictionary dictionaryWithObjects:forKeys:count:] + 59
4 AppCreator 0x000000010d890e1e +[PPZebraUI text:withAnnotation:] + 810
5 AppCreator 0x000000010d875c87 -[PPFundingOption titleForDisplay] + 318
6 AppCreator 0x000000010d8b187f -[PPPaymentFundingOptionSelectionCell refreshContent] + 653
7 AppCreator 0x000000010d8b0bfc -[PPPaymentAttributeSelectionCell initWithViewController:withTitle:withPickerTitle:withDataSource:] + 1293
8 AppCreator 0x000000010d88db04 -[PPSelectPayMethodViewController paymentAttributeSelectionCells] + 310
9 AppCreator 0x000000010d8d4601 -[PPSelectPayMethodViewControllerIOS7 updateTableToConfirm:] + 977
10 AppCreator 0x000000010d8d416e -[PPSelectPayMethodViewControllerIOS7 refreshTable:] + 100
11 AppCreator 0x000000010d8d4229 -[PPSelectPayMethodViewControllerIOS7 viewDidAppear:] + 87
12 UIKit 0x000000010f41d335 -[UIViewController _setViewAppearState:isAnimating:] + 830
13 UIKit 0x000000010f41dcb8 -[UIViewController _endAppearanceTransition:] + 262
14 UIKit 0x000000010f45886f -[UINavigationController navigationTransitionView:didEndTransition:fromView:toView:] + 1290
15 UIKit 0x000000010f44e630 __49-[UINavigationController _startCustomTransition:]_block_invoke + 233
16 UIKit 0x000000010fcaa4c8 -[_UIViewControllerTransitionContext completeTransition:] + 101
17 UIKit 0x000000010f2658a3 __53-[_UINavigationParallaxTransition animateTransition:]_block_invoke95 + 834
18 UIKit 0x000000010f32d53e -[UIViewAnimationBlockDelegate _didEndBlockAnimation:finished:context:] + 644
19 UIKit 0x000000010f30a7ff -[UIViewAnimationState sendDelegateAnimationDidStop:finished:] + 241
20 UIKit 0x000000010f30abae -[UIViewAnimationState animationDidStop:finished:] + 80
21 QuartzCore 0x000000010f12e3c8 _ZN2CA5Layer23run_animation_callbacksEPv + 308
22 libdispatch.dylib 0x000000011440b3eb _dispatch_client_callout + 8
23 libdispatch.dylib 0x00000001143f31ef _dispatch_main_queue_callback_4CF + 1738
24 CoreFoundation 0x0000000113d490f9 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
25 CoreFoundation 0x0000000113d0ab99 __CFRunLoopRun + 2073
26 CoreFoundation 0x0000000113d0a0f8 CFRunLoopRunSpecific + 488
27 GraphicsServices 0x0000000115780ad2 GSEventRunModal + 161
28 UIKit 0x000000010f27cf09 UIApplicationMain + 171
29 AppCreator 0x000000010d3251df main + 111
30 libdyld.dylib 0x000000011444092d start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
I tried the SDk in separated application and it works perfectly .this error happens when i add the sdk to my project .
can anyone please help me what can be causing this error
I found out that problem was in another Library i was using .
It had a function which override the
"preferredFontForTextStyle" in the "UIFont" class
that was causing the problem for me.
in case anyone facing that kind of unjustified crash , try to remove all the other classes one by one to check that the error is not caused by conflict with another line in a far class

Uncaught exception 'NSInvalidArgumentException',reason: 'Receiver .. has no segue'

I just started recently. I can't fix it and I don't know How to do
I have attached files and images. When I run my app, I receive the following error:
2015-11-26 12:17:08.175 login[6107:324531]
*** Terminating app due to uncaught exception 'NSInvalidArgumentException',
reason: 'Receiver (<login.ViewController: 0x7fc0d94b28d0>)
has no segue with identifier 'loginView''
*** First throw call stack:
(
0 CoreFoundation 0x0000000100457f45 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x000000010217bdeb objc_exception_throw + 48
2 UIKit 0x0000000100e099ea -[UIViewController shouldPerformSegueWithIdentifier:sender:] + 0
3 login 0x000000010025fc85 _TFC5login14ViewController13viewDidAppearfS0_FSbT_ + 309
4 login 0x000000010025fce1 _TToFC5login14ViewController13viewDidAppearfS0_FSbT_ + 49
5 UIKit 0x0000000100e0c675 -[UIViewController _setViewAppearState:isAnimating:] + 830
6 UIKit 0x0000000100e0cff8 -[UIViewController _endAppearanceTransition:] + 262
7 UIKit 0x0000000100e47a00 -[UINavigationController navigationTransitionView:didEndTransition:fromView:toView:] + 1290
8 UIKit 0x0000000100e3d917 __49-[UINavigationController _startCustomTransition:]_block_invoke + 233
9 UIKit 0x000000010166db24 -[_UIViewControllerTransitionContext completeTransition:] + 101
10 UIKit 0x0000000100c5cf4a __53-[_UINavigationParallaxTransition animateTransition:]_block_invoke93 + 834
11 UIKit 0x0000000100d1eace -[UIViewAnimationBlockDelegate _didEndBlockAnimation:finished:context:] + 644
12 UIKit 0x0000000100cfc9df -[UIViewAnimationState sendDelegateAnimationDidStop:finished:] + 241
13 UIKit 0x0000000100cfcd8e -[UIViewAnimationState animationDidStop:finished:] + 80
14 QuartzCore 0x00000001051b9fa0 _ZN2CA5Layer23run_animation_callbacksEPv + 308
15 libdispatch.dylib 0x0000000102c4f49b _dispatch_client_callout + 8
16 libdispatch.dylib 0x0000000102c372af _dispatch_main_queue_callback_4CF + 1738
17 CoreFoundation 0x00000001003b82e9 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
18 CoreFoundation 0x00000001003798a9 __CFRunLoopRun + 2073
19 CoreFoundation 0x0000000100378e08 CFRunLoopRunSpecific + 488
20 GraphicsServices 0x0000000104a4bad2 GSEventRunModal + 161
21 UIKit 0x0000000100c7430d UIApplicationMain + 171
22 login 0x00000001002630dd main + 109
23 libdyld.dylib 0x0000000102c8392d start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
My screenshots of code are here:
Screenshots of code
Your error tells you exactly what you need to do.
Receiver (<login.ViewController: 0x7fc0d94b28d0>) has no segue with identifier 'loginView'
so check your segue in storyboard and ensure that segue identifier from LoginViewController is loginView.

iOS app crash when keyboard showing on iPad

I have an app which work perfectly on iPhone. But when i starting it on iPad and tap on UITextField it’s crash with error:
Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayM objectAtIndex:]: index 1 beyond bounds [0 .. 0]'
*** First throw call stack:
(
0 CoreFoundation 0x032a05e4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x02c1e8b6 objc_exception_throw + 44
2 CoreFoundation 0x032414e6 -[__NSArrayM objectAtIndex:] + 246
3 Parking 0x002b0ccd -[UIView(Hackery) pd_swizzled_exchangeSubviewAtIndex:withSubviewAtIndex:] + 141
4 UIKit 0x020a89ef -[_UIBackdropView ensureProperSubviewOrdering] + 666
5 UIKit 0x020a810e -[_UIBackdropView updateSubviewHierarchyIfNeededForSettings:] + 127
6 UIKit 0x020a47dc -[_UIBackdropView setComputesColorSettings:] + 235
7 UIKit 0x01b1c87a -[UIKBBackdropView triggerUpdate:] + 400
8 Foundation 0x028f1bf9 __57-[NSNotificationCenter addObserver:selector:name:object:]_block_invoke + 40
9 CoreFoundation 0x032fc524 __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 20
10 CoreFoundation 0x0325400b _CFXNotificationPost + 2859
11 Foundation 0x0282b951 -[NSNotificationCenter postNotificationName:object:userInfo:] + 98
12 UIKit 0x01e1cb1b -[UIInputViewTransition postNotificationsForTransitionEnd] + 1054
13 UIKit 0x0c69c453 -[UIInputViewTransitionAccessibility(SafeCategory) postNotificationsForTransitionEnd] + 51
14 UIKit 0x01e13138 __53-[UIPeripheralHost(UIKitInternal) executeTransition:]_block_invoke1332 + 455
15 UIKit 0x019ef005 -[UIViewAnimationBlockDelegate _didEndBlockAnimation:finished:context:] + 306
16 UIKit 0x019d8c6c -[UIViewAnimationState sendDelegateAnimationDidStop:finished:] + 267
17 UIKit 0x019d8f58 -[UIViewAnimationState animationDidStop:finished:] + 80
18 UIKit 0x0c6a4b67 -[UIViewAnimationStateAccessibility(SafeCategory) animationDidStop:finished:] + 66
19 QuartzCore 0x00821a44 _ZN2CA5Layer23run_animation_callbacksEPv + 304
20 libdispatch.dylib 0x0362b4b0 _dispatch_client_callout + 14
21 libdispatch.dylib 0x0361975e _dispatch_main_queue_callback_4CF + 340
22 CoreFoundation 0x03305a5e __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 14
23 CoreFoundation 0x032466bb __CFRunLoopRun + 1963
24 CoreFoundation 0x03245ac3 CFRunLoopRunSpecific + 467
25 CoreFoundation 0x032458db CFRunLoopRunInMode + 123
26 GraphicsServices 0x03f7d9e2 GSEventRunModal + 192
27 GraphicsServices 0x03f7d809 GSEventRun + 104
28 UIKit 0x0198cd3b UIApplicationMain + 1225
29 Parking 0x00073cad main + 141
30 libdyld.dylib 0x038bd70d start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
I tried comment all my code to find a reason. Even created an empty view controller and add text field to it. But it’s didn't helped. Any idea?
It is an issue with PonyDebugger which has been fixed in the latest release. Use a version >= 0.3.1.
pod 'PonyDebugger', '~> 0.3.1'

Resources