Error when getting AppDelegate instance in other UIViewController - ios

Hello I have been seeing crash logs for my app which when I open in XCode highlights the following line
let appDelegate = UIApplication.shared.delegate as! AppDelegate
I am stumped as I cannot replicate this in XCode. What are the possible reasons the app may crash here?
This line is at viewDidAppear() and also at viewDidLoad() but 5 out of 5 crash reports all point to the line at viewDidAppear()
Edit:
Here's the crash log
Thread 0 name:
Thread 0 Crashed:
0 MyApp 0x0000000100531208 LoginViewController.initView() + 536 (LoginViewController.swift:107)
1 MyApp 0x0000000100530d88 #objc LoginViewController.viewDidAppear(_:) + 112 (LoginViewController.swift:58)
2 UIKit 0x000000018ee2973c -[UIViewController _setViewAppearState:isAnimating:] + 840 (UIViewController.m:4471)
3 UIKit 0x000000018f07a448 __64-[UIViewController viewDidMoveToWindow:shouldAppearOrDisappear:]_block_invoke + 44 (UIViewController.m:5055)
4 UIKit 0x000000018ee7f798 -[UIViewController _executeAfterAppearanceBlock] + 92 (UIViewController.m:4793)
5 UIKit 0x000000018f185990 _runAfterCACommitDeferredBlocks + 564 (UIApplication.m:2528)
6 UIKit 0x000000018f17b958 _cleanUpAfterCAFlushAndRunDeferredBlocks + 384 (UIApplication.m:2497)
7 UIKit 0x000000018f18c68c __34-[UIApplication _firstCommitBlock]_block_invoke_2 + 152 (UIApplication.m:9928)
8 CoreFoundation 0x00000001851372bc __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ + 20 (CFRunLoop.c:1840)
9 CoreFoundation 0x0000000185136a7c __CFRunLoopDoBlocks + 264 (CFRunLoop.c:1881)
10 CoreFoundation 0x00000001851347b0 __CFRunLoopRun + 1224 (CFRunLoop.c:2922)
11 CoreFoundation 0x0000000185054da8 CFRunLoopRunSpecific + 552 (CFRunLoop.c:3245)
12 GraphicsServices 0x000000018703a020 GSEventRunModal + 100 (GSEvent.c:2245)
13 UIKit 0x000000018f074758 UIApplicationMain + 236 (UIApplication.m:3965)
14 MyApp 0x0000000100424f3c main + 56 (BaseViewController.swift:19)
15 libdyld.dylib 0x0000000184ae5fc0 start + 4

I found this delegate is optional value.
unowned(unsafe) open var delegate: UIApplicationDelegate?
So you should use it like this.
if let appDelegate = UIApplication.shared.delegate as? AppDelegate {
// code here
} else {
// error handle
}

I finally figured this out. The crash logs all point to this line
let appDelegate = UIApplication.shared.delegate as! AppDelegate
which is line 107 from my LoginViewController but the actual error is actually triggered by a line of code two lines prior (data related error). Don't know why the logs all point to line 107 though. Thanks for your help.

Related

iOS app is only crashing on TestFlight build

I have an ios app in Swift.The app runs fine and does not crash when uploaded locally from xcode. But the app is crashing when uploaded from testflight.
I found that there is nothing wrong in code.
I have implemented Crashlytics in my app, it has given following report.
Crashed: com.apple.main-thread
EXC_BREAKPOINT 0x0000000100160fe4
Crashed: com.apple.main-thread
0 App 0x100160fe4 HomeViewController.viewDidLoad() -> () (HomeViewController.swift:57)
1 App 0x100161014 #objc HomeViewController.viewDidLoad() -> () (HomeViewController.swift)
2 UIKit 0x18c373ec0 -[UIViewController loadViewIfRequired] + 1036
3 UIKit 0x18c38b94c -[UIViewController __viewWillAppear:] + 132
4 UIKit 0x18c5101d4 -[UINavigationController _startCustomTransition:] + 1144
5 UIKit 0x18c42ab78 -[UINavigationController _startDeferredTransitionIfNeeded:] + 676
6 UIKit 0x18c42a7e0 -[UINavigationController __viewWillLayoutSubviews] + 64
7 UIKit 0x18c42a744 -[UILayoutContainerView layoutSubviews] + 188
8 UIKit 0x18c37107c -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 1200
9 QuartzCore 0x189561274 -[CALayer layoutSublayers] + 148
10 QuartzCore 0x189555de8 CA::Layer::layout_if_needed(CA::Transaction*) + 292
11 QuartzCore 0x189555ca8 CA::Layer::layout_and_display_if_needed(CA::Transaction*) + 32
12 QuartzCore 0x1894d134c CA::Context::commit_transaction(CA::Transaction*) + 252
13 QuartzCore 0x1894f83ac CA::Transaction::commit() + 504
14 QuartzCore 0x1894f8e78 CA::Transaction::observer_callback(__CFRunLoopObserver*, unsigned long, void*) + 120
15 CoreFoundation 0x1861f09a8 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 32
16 CoreFoundation 0x1861ee630 __CFRunLoopDoObservers + 372
17 CoreFoundation 0x1861eea7c __CFRunLoopRun + 956
18 CoreFoundation 0x18611eda4 CFRunLoopRunSpecific + 424
19 GraphicsServices 0x187b88074 GSEventRunModal + 100
20 UIKit 0x18c3d9058 UIApplicationMain + 208
21 App 0x1000d8688 main (NewProductData.swift:18)
22 libdyld.dylib 0x18512d59c start + 4
I am not understanding anything from this reports, please help me out if anyone knows.
Here is viewDidload
override func viewDidLoad() {
super.viewDidLoad()
Giving instance of HomeViewController to AppDelegate
let appDele = UIApplication.shared.delegate as! AppDelegate
appDele.homeVC = self
token = FIRInstanceID.instanceID().token()!
//Method to handle Firebase token
UserDefaults.standard.set(token, forKey: "Notificationtoken")
print("####################### token provided is \(String(describing: token))")
let tokenstr = UserDefaults.standard.value(forKey: "Notificationtoken") as! String
if(token == tokenstr){
handleFCMToken(token: tokenstr)
}
else{
handleFCMToken(token: token!)
}
setUpNavBar()
setPopUpImage()
setUpcarousel()
setUpDelegates()
let help = Helper()
help.setUpGoogleAnalytics(screenName: "Home")
self.presenter = HomeViewPresenter(homeView: self)
presenter.getCarousel()
if(showProfile){
ProfileClicked()
}
// Do any additional setup after loading the view.
}
And here is viewWillAppear
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
setUpUI()
}
and method of setupUI
func setUpUI(){
let wholesaler:Wholesaler = Helper.getWsProfile()
DispatchQueue.main.async {
self.wholesalerName.text = "Hello, \(wholesaler.wholesaler_name)"
self.pdsPoints.text = "\(wholesaler.pdsPoints!)"
self.visibilityPoints.text = "\(wholesaler.visibilityPoins!)"
}
iconNameString = ["SMS","Customer\n Groups","Visibility\n Contest","My\n Earnings","\(wholesaler.lastSchemeMonth!)\n Schemes","App\n News", "", "Contact\n Us"]
}
I think that viewing some code of your HomeViewController will give us more insight.
But here some comments:
Not sure about the full stack, but its seems weird that viewWillAppear is being called before viewDidLoad for some reason. Are you calling super correctly on those corresponding methods?
Have you try profiling the app using instruments in release mode vs debug mode? You can manage this on your schema settings.
Another hint, but I think it kind of advanced for your scenario, is the optimization level. Go to your target settings and search for Optimization Level, you'll notice it is different for debug and release. Sometimes complex algorithms with multiple blocks and/or threads may be affected by this.
Home it helps

Why "Unknown class"?

I am a beginner in programming, and new to Stack Overflow as well. I'm still figuring out how codes and this website work, so I'm sorry if I didn't use them correctly. (I'm not a native English speaker, but I'll do my best to explain my question as well as possible)
I'm using Xcode Version 8.1, and Swift.
I'm building an app for my school project. I've already created To-Do-List App and Countdown Timer App. So, I want to put them together in one app now.
I created a new project and inserted Tab Bar Controller. Then copied all the files I used in To-Do-List and Countdown Timer apps, and set up the storyboard.
There are no caution marks, but when I run the simulator, an error comes up and the simulator stops. The error I got is "Thread 1: signal SIGABRT" in this line in AppDelegate.swift:
class AppDelegate: UIResponder, UIApplicationDelegate {
and the message in the console is:
2017-01-06 20:32:22.207 PP Final App[61701:3259153] Unknown class PomodoroViewController in Interface Builder file.
2017-01-06 20:32:22.713 PP Final App[61701:3259153] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<UIViewController 0x7fd7faf075d0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key lbTimer.'
*** First throw call stack:
(
0 CoreFoundation 0x00000001100c234b __exceptionPreprocess + 171
1 libobjc.A.dylib 0x000000010fb2321e objc_exception_throw + 48
2 CoreFoundation 0x00000001100c2299 -[NSException raise] + 9
3 Foundation 0x000000010f63326f -[NSObject(NSKeyValueCoding) setValue:forKey:] + 291
4 UIKit 0x000000011067f4ef -[UIViewController setValue:forKey:] + 88
5 UIKit 0x00000001108f379e -[UIRuntimeOutletConnection connect] + 109
6 CoreFoundation 0x0000000110067590 -[NSArray makeObjectsPerformSelector:] + 256
7 UIKit 0x00000001108f2122 -[UINib instantiateWithOwner:options:] + 1867
8 UIKit 0x0000000110685c21 -[UIViewController _loadViewFromNibNamed:bundle:] + 386
9 UIKit 0x0000000110686543 -[UIViewController loadView] + 177
10 UIKit 0x0000000110686878 -[UIViewController loadViewIfRequired] + 201
11 UIKit 0x00000001106870cc -[UIViewController view] + 27
12 UIKit 0x00000001106e52df -[UITabBarController transitionFromViewController:toViewController:transition:shouldSetSelected:] + 483
13 UIKit 0x00000001106e4721 -[UITabBarController transitionFromViewController:toViewController:] + 59
14 UIKit 0x00000001106e05e2 -[UITabBarController _setSelectedViewController:] + 365
15 UIKit 0x00000001106e0464 -[UITabBarController setSelectedViewController:] + 234
16 UIKit 0x000000011059e6e6 +[UIView(Animation) performWithoutAnimation:] + 90
17 UIKit 0x00000001106daa00 -[UITabBarController _selectDefaultViewControllerIfNecessaryWithAppearanceTransitions:] + 354
18 UIKit 0x00000001106dbb7a -[UITabBarController viewWillAppear:] + 206
19 UIKit 0x000000011068ca0f -[UIViewController _setViewAppearState:isAnimating:] + 692
20 UIKit 0x000000011068d11f -[UIViewController __viewWillAppear:] + 147
21 UIKit 0x000000011068e913 -[UIViewController viewWillMoveToWindow:] + 507
22 UIKit 0x0000000110595151 -[UIView(Hierarchy) _willMoveToWindow:withAncestorView:] + 621
23 UIKit 0x00000001105a5cf0 -[UIView(Internal) _addSubview:positioned:relativeTo:] + 451
24 UIKit 0x00000001105947a1 -[UIView(Hierarchy) addSubview:] + 838
25 UIKit 0x0000000110550f5b -[UIWindow addRootViewControllerViewIfPossible] + 849
26 UIKit 0x00000001105513a2 -[UIWindow _setHidden:forced:] + 293
27 UIKit 0x0000000110564cb5 -[UIWindow makeKeyAndVisible] + 42
28 UIKit 0x00000001104ddc89 -[UIApplication _callInitializationDelegatesForMainScene:transitionContext:] + 4818
29 UIKit 0x00000001104e3de9 -[UIApplication _runWithMainScene:transitionContext:completion:] + 1731
30 UIKit 0x00000001104e0f69 -[UIApplication workspaceDidEndTransaction:] + 188
31 FrontBoardServices 0x0000000113ed3723 __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__ + 24
32 FrontBoardServices 0x0000000113ed359c -[FBSSerialQueue _performNext] + 189
33 FrontBoardServices 0x0000000113ed3925 -[FBSSerialQueue _performNextFromRunLoopSource] + 45
34 CoreFoundation 0x0000000110067311 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
35 CoreFoundation 0x000000011004c59c __CFRunLoopDoSources0 + 556
36 CoreFoundation 0x000000011004ba86 __CFRunLoopRun + 918
37 CoreFoundation 0x000000011004b494 CFRunLoopRunSpecific + 420
38 UIKit 0x00000001104df7e6 -[UIApplication _run] + 434
39 UIKit 0x00000001104e5964 UIApplicationMain + 159
40 PP Final App 0x000000010f52c1cf main + 111
41 libdyld.dylib 0x000000011373c68d start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
In this message, I see "Unknown class PomodoroViewController in Interface Builder file." This is the problem, right? But I don't know why I got this message. Are there any problems in the file?
Is the way I use Tab Bar Controller right?
Here's the code file of Pomodoro View Controller:
PomodoroViewController
import UIKit
class PomodoroViewController: UIViewController {
#IBOutlet weak var lbTimer: UILabel!
let pomodoroTime: TimeInterval = 60 * 25 //Pomodoro Timer 25 minutes
let formatter = DateFormatter()
var theTime: TimeInterval = 0.0
override func viewDidLoad(){
super.viewDidLoad()
formatter.dateFormat = "mm:ss"
let startTime = Date(timeIntervalSinceReferenceDate: pomodoroTime)
lbTimer.text = formatter.string(from: startTime)
}
override func didReceiveMemoryWarning(){
super.didReceiveMemoryWarning()
}
#IBAction func countDown(_ sender: UIButton) {
theTime = pomodoroTime
Timer.scheduledTimer(timeInterval: 1.0,
target: self,
selector: #selector(PomodoroViewController.tickTimer(timer:)),
userInfo: nil,
repeats: true)
}
func tickTimer(timer: Timer){
theTime -= 1.0
let newTime = Date(timeIntervalSinceReferenceDate: theTime)
if theTime < 0.1 {
timer.invalidate()
}
}
}
and this is how the storyboard looks like:
storyboard
What this error means is:
You have a storyboard (or maybe a xib) that says that one of the view controllers is a PomodoroViewController. But...
PomodoroViewController does not exist when the app is running.
The message says that iOS tried to find PomodoroViewController but it wasn't there, so it tried to use UIViewController instead. Except UIViewController doesn't have the lbTimer property, which makes the app crash.
There are a couple of reasons this could happen:
You might have forgotten to copy PomodoroViewController to the new project.
If you did copy it, you might not be including it in the app target. [Files can be included in the Xcode project that don't get compiled, because you might use the same project file for more than one target.]
In the second case, make sure that the file is checked in the file inspector on the right side of the Xcode window:

iOS Exception Backtrace - App entry not symbolicating

I have received the below exception backtrace from Apple for an app I had submitted to the app store. I have symbolicated the log but my app's entry has not symbolicated. Any idea what I can do to achieve that? Please see Entry # 14 below which provides more detail. Any help would be much appreciated
Last Exception Backtrace:
0 CoreFoundation 0x1810cadb0 __exceptionPreprocess + 124
1 libobjc.A.dylib 0x18072ff80 objc_exception_throw + 56
2 UIKit 0x186b6d268 -[UIPopoverPresentationController presentationTransitionWillBegin] + 2884
3 UIKit 0x186581fb0 __71-[UIPresentationController _initViewHierarchyForPresentationSuperview:]_block_invoke + 1640
4 UIKit 0x1865800c8 __56-[UIPresentationController runTransitionForCurrentState]_block_invoke + 332
5 UIKit 0x1864d30c8 _runAfterCACommitDeferredBlocks + 292
6 UIKit 0x1864e0a80 _cleanUpAfterCAFlushAndRunDeferredBlocks + 92
7 UIKit 0x1862125a4 _afterCACommitHandler + 96
8 CoreFoundation 0x181080728 _CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 32
9 CoreFoundation 0x18107e4cc __CFRunLoopDoObservers + 372
10 CoreFoundation 0x18107e8fc __CFRunLoopRun + 928
11 CoreFoundation 0x180fa8c50 CFRunLoopRunSpecific + 384
12 GraphicsServices 0x182890088 GSEventRunModal + 180
13 UIKit 0x18628a088 UIApplicationMain + 204
14 MyApp 0x1000fb144 0x1000e4000 + 94532
15 libdyld.dylib 0x180b468b8 start + 4
Finally solved the problem. I was invoking UIAlertController in my code to present an action sheet with various options. To cater to devices that don't have a camera, I had added a conditional statement to directly present an ImagePicker instead of an action sheet.
iPAD testing was carried out only on the simulator which doesn't have a camera, thus directly invoking the ImagePicker. When he Conditional statement was removed, it tried presenting the Action Sheet through a PopoverPresentationController and crashed - as is evident in statement 2 of the Exception Backtrace.
I subsequently added the following code to fix the oversight:
if let popOver = optionMenu.popoverPresentationController {
popOver.sourceRect = sender.bounds
popOver.sourceView = sender
}

Parse.com error 'Method not allowed when Pinning is enabled.' when I use a PFQueryTableViewController subclass

I am currently using 1.6.1 via CocoaPods (= latest)
In my swift project I enable the localdatastore and then set the parse application id.
After that, I load a storyboard which is a PFQueryTableViewController subclass.
Really nothing special there. But it still crashes.
It seems to crash in Parse internally on [PFQuery setCachePolicy:]
What could be wrong? How do I make offline functionality working?
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Method not allowed when Pinning is enabled.'
*** First throw call stack:
(
0 CoreFoundation 0x00000001078a0f35 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x0000000107ea3bb7 objc_exception_throw + 45
2 CoreFoundation 0x00000001078a0e6d +[NSException raise:format:] + 205
3 NMC-Goes 0x00000001044abe44 -[PFQuery setCachePolicy:] + 35
4 NMC-Goes 0x00000001043f6e85 -[PFQueryTableViewController queryForTable] + 341
5 NMC-Goes 0x00000001043f712e -[PFQueryTableViewController loadObjects:clear:] + 110
6 NMC-Goes 0x00000001043f70ba -[PFQueryTableViewController loadObjects] + 58
7 NMC-Goes 0x00000001043f69f9 -[PFQueryTableViewController viewDidLoad] + 73
8 NMC-Goes 0x000000010425ae1a _TFC8NMC_Goes23TripTableViewController11viewDidLoadfS0_FT_T_ + 74
9 NMC-Goes 0x000000010425bca2 _TToFC8NMC_Goes23TripTableViewController11viewDidLoadfS0_FT_T_ + 34
10 UIKit 0x00000001063f3a90 -[UIViewController loadViewIfRequired] + 738
11 UIKit 0x000000010642206b -[UINavigationController _layoutViewController:] + 44
12 UIKit 0x00000001064225b5 -[UINavigationController _updateScrollViewFromViewController:toViewController:] + 216
13 UIKit 0x00000001064226b4 -[UINavigationController _startTransition:fromViewController:toViewController:] + 92
14 UIKit 0x0000000106423487 -[UINavigationController _startDeferredTransitionIfNeeded:] + 523
15 UIKit 0x0000000106423f47 -[UINavigationController __viewWillLayoutSubviews] + 43
16 UIKit 0x0000000106569509 -[UILayoutContainerView layoutSubviews] + 202
17 UIKit 0x0000000106347973 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 521
18 QuartzCore 0x0000000105fdbde8 -[CALayer layoutSublayers] + 150
19 QuartzCore 0x0000000105fd0a0e _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 380
20 QuartzCore 0x0000000105fd087e _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 24
21 QuartzCore 0x0000000105f3e63e _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 242
22 QuartzCore 0x0000000105f3f74a _ZN2CA11Transaction6commitEv + 390
23 UIKit 0x00000001062cc54d -[UIApplication _reportMainSceneUpdateFinished:] + 44
24 UIKit 0x00000001062cd238 -[UIApplication _runWithMainScene:transitionContext:completion:] + 2642
25 UIKit 0x00000001062cbbf2 -[UIApplication workspaceDidEndTransaction:] + 179
26 FrontBoardServices 0x000000010b6a12a3 __31-[FBSSerialQueue performAsync:]_block_invoke + 16
27 CoreFoundation 0x00000001077d653c __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ + 12
28 CoreFoundation 0x00000001077cc285 __CFRunLoopDoBlocks + 341
29 CoreFoundation 0x00000001077cc045 __CFRunLoopRun + 2389
30 CoreFoundation 0x00000001077cb486 CFRunLoopRunSpecific + 470
31 UIKit 0x00000001062cb669 -[UIApplication _run] + 413
32 UIKit 0x00000001062ce420 UIApplicationMain + 1282
33 NMC-Goes 0x000000010427840e top_level_code + 78
34 NMC-Goes 0x00000001042784ea main + 42
35 libdyld.dylib 0x000000010877a145 start + 1
36 ??? 0x0000000000000001 0x0 + 1
)
You cannot use the old query caching policies when pinning is enabled.
See here:
PFQuery Class Reference - cachePolicy
I've made an example project to demo the problem to Parse.com (see the bug: https://developers.facebook.com/bugs/1544122569192939/).
The response that I got from Parse was that the ParseUI framework from cocoapods is known to have this problem.
They suggested I get ParseUI from https://parse.com/docs/downloads
I'll try and see if that fixes the problem with my PFQueryTableViewController
Edit: I've added the framework manually and took it out of the Podfile. The crash now no longer occurs. So the bug is in the ParseUI cocoapod like parse told me on developers.facebook.com
I also faced the same problem. I commented below line from classes which extends PFQueryTableViewController & it worked for me.
if ([self.objects count] == 0) {
query.cachePolicy = kPFCachePolicyCacheThenNetworkd;
}
I had got the exact stack trace thrown when I was trying out Parse. But then figured out that I had included this line of code in my app delegate.
Objective-C
[Parse enableLocalDatastore];
I removed this code and it worked like a charm.
Swift
Remove:
Parse.enableLocalDatastore()
//
// AppDelegate.swift
import UIKit
import Parse
import Bolts
#UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject : AnyObject]?) -> Bool {
Parse.enableLocalDatastore()
Parse.setApplicationId("#######", clientKey: "#####")
PFAnalytics.trackAppOpenedWithLaunchOptions(launchOptions)
return true
}
setApplicationID inside App Delegate instead of Controller solves the problem for me.
you can try this code in swift.
if [self.objects].count == 0 {
query?.cachePolicy = PFCachePolicy.CacheThenNetwork
}
I added 'import Bolts' below:
import UIKit
import Parse
As shown in the screen shot.
This fixed the issue for me.

Getting crash can't add self as subview in ios

Can't reproduce following crash.
I already handled the case : not segueing the viewcontroller while one viewcontroller is animating. Similar problem mentioned here: iOS app error - Can't add self as subview. I have implemented this solution for safe segueing.
Still I am getting following crash.
Note: getting crash on both iOS 7 and 8 but more crash occurrence for iOS 8.(if that helps). Not getting crash in simulator even if segueing from viewDidLoad.
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Can't add self as subview'
Application Specific Backtrace 1:
0 CoreFoundation 0x24503f87 <redacted> + 126
1 libobjc.A.dylib 0x31c62c77 _objc_exception_throw + 38
2 CoreFoundation 0x24503ecd -[NSException initWithCoder:] + 0
3 UIKit 0x279880b3 -[UIView _addSubview:positioned:relativeTo:] + 114
4 UIKit 0x27988037 -[UIView addSubview:] + 30
5 UIKit 0x27b4d491 <redacted> + 1236
6 UIKit 0x2798e701 +[UIView performWithoutAnimation:] + 72
7 UIKit 0x27b4cd79 -[_UINavigationParallaxTransition animateTransition:] + 808
8 UIKit 0x27b0b787 -[UINavigationController _startCustomTransition:] + 2854
9 UIKit 0x27a2ab2f -[UINavigationController _startDeferredTransitionIfNeeded:] + 422
10 UIKit 0x27a2a931 -[UINavigationController __viewWillLayoutSubviews] + 44
11 UIKit 0x27a2a8c9 -[UILayoutContainerView layoutSubviews] + 184
12 UIKit 0x2797f25f -[UIView layoutSublayersOfLayer:] + 514
13 QuartzCore 0x273aa1d5 -[CALayer layoutSublayers] + 136
14 QuartzCore 0x273a5bd1 <redacted> + 360
15 QuartzCore 0x273a5a59 <redacted> + 16
16 QuartzCore 0x273a5447 <redacted> + 222
17 QuartzCore 0x273a5251 <redacted> + 324
18 UIKit 0x27980c31 <redacted> + 1384
19 CoreFoundation 0x244ca807 <redacted> + 14
20 CoreFoundation 0x244c9c1b <redacted> + 222
21 CoreFoundation 0x244c8299 <redacted> + 768
22 CoreFoundation 0x24415db1 _CFRunLoopRunSpecific + 476
23 CoreFoundation 0x24415bc3 _CFRunLoopRunInMode + 106
24 GraphicsServices 0x2b7a0051 _GSEventRunModal + 136
25 UIKit 0x279e0f01 _UIApplicationMain + 1440
This also happens when for some reason you push the segue / viewcontroller multiple times. One of such case is when you are observing for a notification and if for some reason that notification was posted multiple times and in the observing method, if you were pushing a view controller, it will push to more than once which eventually will cause this kind of crash.
Sorry for being late for the party. I recently had this issue wherein my navigationbar goes into corrupted state because of pushing more than one view controller at the same time. This happens because the other view controller is pushed while the first view controller is still animating. Taking hint from the nonamelive answer from here
I came up with my simple solution that works in my case. You just need to subclass UINavigationController and override the pushViewController method and check if previous view controller animation is finished as yet. You can listen to the animation completion by making your class a delegate of UINavigationControllerDelegate and setting the delegate to self.
I have uploaded a gist here to make things simple.
Just make sure you set this new class as the NavigationController in your storyboard.

Resources