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