What is causing my "unrecognized selector" exception? - ios

I am independently going through the Programming iOS 7 course on iTunes U from Stanford, and therefore now that I have a question and I can't ask the teacher, I'm hoping someone here can help me out. Ideally by telling me how to track down this type of problem, but I'm also posting my entire project at http://talix.homeip.net/2014/Matchismo.zip (since I don't think I can usefully post the UI for you to debug it in this post like normal text code), so just telling me where specifically the problem is would be very much appreciated as well! I'm in the middle of assignment 3 for anyone who has taken the same course.
I've got a very basic card matching game that can play with playing cards or "Set". The playing card tab works great. The Set tab crashes with an uncaught exception (copied below) as soon as I press the New Game button or click on a card (which results in starting a new game). I have put a breakpoint in my code so that I catch the New Game action, and stepped through all of the resulting code. It all seems to work fine when I am stepping through my code. When I reach the end of the last of my functions that get called as a result of the action, and then I press Continue in XCode, that's when it crashes. Given that fact, I'm not sure how to trace what exactly is causing the problem.
Another question: Is it useful to post the entire call stack from the exception text, or are the top couple lines the only really useful ones (for beginners like me at least)? I think I see that the unrecognized selector in question is [__NSCFConstantString _isDefaultFace]:, but I don't know where that would be getting called as part of what I'm assuming is UI code behind the types of classes I use (UILabel, etc.).
Here is the whole exception text just in case:
2014-09-28 18:45:54.337 Matchismo[17292:2714082] -[__NSCFConstantString _isDefaultFace]: unrecognized selector sent to instance 0xc721c
2014-09-28 18:45:54.346 Matchismo[17292:2714082] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFConstantString _isDefaultFace]: unrecognized selector sent to instance 0xc721c'
*** First throw call stack:
(
0 CoreFoundation 0x01cfddf6 __exceptionPreprocess + 182
1 libobjc.A.dylib 0x01987a97 objc_exception_throw + 44
2 CoreFoundation 0x01d05a75 -[NSObject(NSObject) doesNotRecognizeSelector:] + 277
3 CoreFoundation 0x01c4e9c7 ___forwarding___ + 1047
4 CoreFoundation 0x01c4e58e _CF_forwarding_prep_0 + 14
5 UIFoundation 0x0355a1a9 -[NSMutableAttributedString(NSMutableAttributedStringKitAdditions) fixFontAttributeInRange:] + 2593
6 UIFoundation 0x035596b6 -[NSMutableAttributedString(NSMutableAttributedStringKitAdditions) fixAttributesInRange:] + 132
7 UIFoundation 0x0356b371 __NSStringDrawingEngine + 6661
8 UIFoundation 0x03571c00 -[NSAttributedString(NSExtendedStringDrawing) boundingRectWithSize:options:context:] + 1311
9 UIKit 0x0068fd5e -[UIButton _intrinsicSizeWithinSize:] + 825
10 UIKit 0x00ae4be6 -[UIView(UIConstraintBasedLayout) intrinsicContentSize] + 51
11 UIKit 0x00ae51e5 -[UIView(UIConstraintBasedLayout) _generateContentSizeConstraints] + 36
12 UIKit 0x00ae4f16 -[UIView(UIConstraintBasedLayout) _updateContentSizeConstraints] + 505
13 UIKit 0x00aed1aa -[UIView(AdditionalLayoutSupport) updateConstraints] + 185
14 UIKit 0x0068f7e1 -[UIButton updateConstraints] + 3366
15 UIKit 0x00aec614 -[UIView(AdditionalLayoutSupport) _internalUpdateConstraintsIfNeededAccumulatingViewsNeedingSecondPassAndViewsNeedingBaselineUpdate:] + 259
16 UIKit 0x00aec861 -[UIView(AdditionalLayoutSupport) _updateConstraintsIfNeededAccumulatingViewsNeedingSecondPassAndViewsNeedingBaselineUpdate:] + 127
17 UIKit 0x00aec7dc __UIViewRecursionHelper + 41
18 CoreFoundation 0x01bf29b9 CFArrayApplyFunction + 57
19 UIKit 0x00aec5af -[UIView(AdditionalLayoutSupport) _internalUpdateConstraintsIfNeededAccumulatingViewsNeedingSecondPassAndViewsNeedingBaselineUpdate:] + 158
20 UIKit 0x00aec894 __125-[UIView(AdditionalLayoutSupport) _updateConstraintsIfNeededAccumulatingViewsNeedingSecondPassAndViewsNeedingBaselineUpdate:]_block_invoke + 43
21 Foundation 0x015766f7 -[NSISEngine withBehaviors:performModifications:] + 150
22 Foundation 0x01579c4f -[NSISEngine withAutomaticOptimizationDisabled:] + 48
23 UIKit 0x00aec3fb -[UIView(AdditionalLayoutSupport) _withAutomaticEngineOptimizationDisabledIfEngineExists:] + 64
24 UIKit 0x00aec861 -[UIView(AdditionalLayoutSupport) _updateConstraintsIfNeededAccumulatingViewsNeedingSecondPassAndViewsNeedingBaselineUpdate:] + 127
25 UIKit 0x00aecdf6 __60-[UIView(AdditionalLayoutSupport) updateConstraintsIfNeeded]_block_invoke + 105
26 Foundation 0x015766f7 -[NSISEngine withBehaviors:performModifications:] + 150
27 Foundation 0x01579c4f -[NSISEngine withAutomaticOptimizationDisabled:] + 48
28 UIKit 0x00aec3fb -[UIView(AdditionalLayoutSupport) _withAutomaticEngineOptimizationDisabledIfEngineExists:] + 64
29 UIKit 0x00aeca4c -[UIView(AdditionalLayoutSupport) updateConstraintsIfNeeded] + 248
30 UIKit 0x00aed27e -[UIView(AdditionalLayoutSupport) _updateConstraintsAtEngineLevelIfNeeded] + 170
31 UIKit 0x003eec9e -[UIView(Hierarchy) _updateConstraintsAsNecessaryAndApplyLayoutFromEngine] + 120
32 UIKit 0x003eef9c -[UIView(Hierarchy) layoutSubviews] + 57
33 UIKit 0x003fc9c0 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 608
34 libobjc.A.dylib 0x0199d771 -[NSObject performSelector:withObject:] + 70
35 QuartzCore 0x0462227f -[CALayer layoutSublayers] + 152
36 QuartzCore 0x04616105 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 397
37 QuartzCore 0x04615f60 _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 26
38 QuartzCore 0x04574676 _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 284
39 QuartzCore 0x04575a3c _ZN2CA11Transaction6commitEv + 392
40 QuartzCore 0x0463b789 +[CATransaction flush] + 52
41 UIKit 0x0036e0d3 _UIApplicationHandleEventQueue + 2296
42 CoreFoundation 0x01c217bf __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15
43 CoreFoundation 0x01c172cd __CFRunLoopDoSources0 + 253
44 CoreFoundation 0x01c16828 __CFRunLoopRun + 952
45 CoreFoundation 0x01c161ab CFRunLoopRunSpecific + 443
46 CoreFoundation 0x01c15fdb CFRunLoopRunInMode + 123
47 GraphicsServices 0x0415024f GSEventRunModal + 192
48 GraphicsServices 0x0415008c GSEventRun + 104
49 UIKit 0x00371e16 UIApplicationMain + 1526
50 Matchismo 0x000bd80d main + 141
51 libdyld.dylib 0x022d0ac9 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException

It looks like I can't mark Hot Licks's comment as an answer to give reputation and mark it as the accepted answer, so I will put my own "answer" down here - but he should get the credit! :-)
The problem was I was passing an NSString as the NSFontAttributeName of an NSAttributedString, rather than an UIFont object. Here is the old offending code:
return [[NSAttributedString alloc] initWithString:text attributes:#{NSForegroundColorAttributeName : color,
NSStrokeColorAttributeName : color,
NSStrokeWidthAttributeName : strokeWidth,
NSFontAttributeName : #"System 12.0"}];
And here is the corrected code:
UIFont *font = [UIFont boldSystemFontOfSize:12];
return [[NSAttributedString alloc] initWithString:text attributes:#{NSForegroundColorAttributeName : color,
NSStrokeColorAttributeName : color,
NSStrokeWidthAttributeName : strokeWidth,
NSFontAttributeName : font}];
In retrospect, an obvious mistake, but aren't they always in hindsight? 😉 This is my first time using NSAttributedString, so hopefully I won't make the same mistake again in the future. Thanks again, Hot Licks!
My more long-term and serious question remains: why didn't this code crash when I stepped over it in the debugger, so that I would know what line to focus on?

Related

Understanding the Crash Log

I am an Android Developer and trying some dummy for the iOS development.
I am trying a tutorial for AMSlideMenu and it was working well at a certain point of development.
I followed the complete tutorial and it worked well. After sometime while I was experimenting some other functionality the code breaked.
I undo and reverted back the changes but something still looks wrong.
below is the crash log, but i cant understand what went wrong
*** First throw call stack:
(
0 CoreFoundation 0x000000010bdf93f5 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x000000010b6e9bb7 objc_exception_throw + 45
2 UIKit 0x000000010c7bd43b -[UIViewController shouldPerformSegueWithIdentifier:sender:] + 0
3 Pranshu1 0x000000010b1a0d4f -[AMSlideMenuMainViewController setup] + 1071
4 Pranshu1 0x000000010b19dc63 -[AMSlideMenuMainViewController viewDidLoad] + 419
5 Pranshu1 0x000000010b19d1b6 -[MainViewController viewDidLoad] + 54
6 UIKit 0x000000010c7bb190 -[UIViewController loadViewIfRequired] + 738
7 UIKit 0x000000010c7e95db -[UINavigationController _layoutViewController:] + 44
8 UIKit 0x000000010c7e9b25 -[UINavigationController _updateScrollViewFromViewController:toViewController:] + 216
9 UIKit 0x000000010c7e9c24 -[UINavigationController _startTransition:fromViewController:toViewController:] + 92
10 UIKit 0x000000010c7ea9f7 -[UINavigationController _startDeferredTransitionIfNeeded:] + 523
11 UIKit 0x000000010c7eb4b7 -[UINavigationController __viewWillLayoutSubviews] + 43
12 UIKit 0x000000010c92f399 -[UILayoutContainerView layoutSubviews] + 202
13 UIKit 0x000000010c70f199 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 521
14 QuartzCore 0x000000010c521f98 -[CALayer layoutSublayers] + 150
15 QuartzCore 0x000000010c516bbe _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 380
16 QuartzCore 0x000000010c516a2e _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 24
17 QuartzCore 0x000000010c484ade _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 242
18 QuartzCore 0x000000010c485bea _ZN2CA11Transaction6commitEv + 390
19 UIKit 0x000000010c69467d -[UIApplication _reportMainSceneUpdateFinished:] + 44
20 UIKit 0x000000010c695368 -[UIApplication _runWithMainScene:transitionContext:completion:] + 2642
21 UIKit 0x000000010c693d22 -[UIApplication workspaceDidEndTransaction:] + 179
22 FrontBoardServices 0x00000001114912a3 __31-[FBSSerialQueue performAsync:]_block_invoke + 16
23 CoreFoundation 0x000000010bd2eabc __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ + 12
24 CoreFoundation 0x000000010bd24805 __CFRunLoopDoBlocks + 341
25 CoreFoundation 0x000000010bd245c5 __CFRunLoopRun + 2389
26 CoreFoundation 0x000000010bd23a06 CFRunLoopRunSpecific + 470
27 UIKit 0x000000010c693799 -[UIApplication _run] + 413
28 UIKit 0x000000010c696550 UIApplicationMain + 1282
29 Pranshu1 0x000000010b1ad003 main + 115
30 libdyld.dylib 0x000000010e822145 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
Thanks in Advance
Looking up from the top (0) entry the last of your methods is: Pranshu1 so you need to look there.
The last method is: -[UIViewController shouldPerformSegueWithIdentifier:sender:]
so it looks like you are performing a Segue, check the identifier.
Before that is the method AMSlideMenuMainViewController so it looks like you are probably using the 3rd party code AMSlideMenu, check for correct usage.
Here is how to catch the exceptions at the point of the error:
To see the actual statement that is causing the error add an exception breakpoint:
From the Main Menu Debug:Breakpoints:Create Exception Breakpoint.
Right-click the breakpoint and set the exception to Objective-C.
Add an action: "po $arg1".
Run the app to get the breakpoint and you will be at the line that causes the exception and the error message will be in the debugger console.
Creating the breakpoint example:

"__NSCFString navigationBar" : unrecognized selector sent to instance

Alright Everyone,
I've got a real tough nut to crack. I am getting a very strange crash in my iOS app. During the sequence of closing a UIPopoverController by clicking off of it (on an iPad), this crash is occurring.
The really odd thing here is that it is a crash coming out of UIKit. I have filed a radar report for a very similar issue, but Apple marked it as closed and when asked, did not provide any further information than to say it was a duplicate of another issue (which I can not see).
Has anyone seen anything like this before?
EDIT 1: I can't figure out how to make the below a code block, the code block markup tool didn't do it. If anyone could point that out, that would be great :).
Thanks,
~Arash
-[__NSCFString navigationBar]: unrecognized selector sent to instance 0x7be4f510
2015-06-22 11:12:57.375 SpotlightEnterprise[82694:1472906] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFString navigationBar]: unrecognized selector sent to instance 0x7be4f510'
*** First throw call stack:
(
0 CoreFoundation 0x0522f746 __exceptionPreprocess + 182
1 libobjc.A.dylib 0x04e10a97 objc_exception_throw + 44
2 CoreFoundation 0x05237705 -[NSObject(NSObject) doesNotRecognizeSelector:] + 277
3 CoreFoundation 0x0517e287 ___forwarding___ + 1047
4 CoreFoundation 0x0517de4e _CF_forwarding_prep_0 + 14
5 UIKit 0x03506810 -[UINavigationItemView _updateLabelColor] + 45
6 UIKit 0x03507df3 -[UINavigationItemButtonView tintColorDidChange] + 86
7 UIKit 0x0377d28b -[_UITintColorVisitor _visitView:] + 363
8 UIKit 0x0377dab1 _UIViewVisitorEntertainVisitors + 98
9 UIKit 0x0377cb09 _UIViewVisitorRecursivelyEntertainDescendingVisitors + 166
10 UIKit 0x0377c859 +[_UIViewVisitor _startTraversalOfVisitor:withView:] + 377
11 UIKit 0x03484df1 -[UIView _receiveVisitor:] + 51
12 UIKit 0x0348a4dd -[UIView _dispatchTintColorVisitorWithReasons:] + 143
13 UIKit 0x0348a922 -[UIView setTintAdjustmentMode:] + 116
14 UIKit 0x03551433 -[UIPresentationController _enableOcclusion:] + 423
15 UIKit 0x035515d0 __55-[UIPresentationController _beginOcclusionIfNecessary:]_block_invoke + 44
16 UIKit 0x03c8208b -[_UIViewControllerTransitionCoordinator _applyBlocks:releaseBlocks:] + 198
17 UIKit 0x03c7e9b9 -[_UIViewControllerTransitionContext __runAlongsideAnimations] + 168
18 UIKit 0x03550f49 __56-[UIPresentationController runTransitionForCurrentState]_block_invoke392 + 67
19 UIKit 0x03481b3e -[UIViewAnimationState _runAlongsideAnimations] + 37
20 UIKit 0x03481182 -[UIViewAnimationState pop] + 36
21 UIKit 0x0347ff6e +[UIViewAnimationState popAnimationState] + 47
22 UIKit 0x0349ec6e +[UIView(UIViewAnimationWithBlocks) _setupAnimationWithDuration:delay:view:options:factory:animations:start:animationStateGenerator:completion:] + 518
23 UIKit 0x0349f017 +[UIView(UIViewAnimationWithBlocks) animateWithDuration:delay:options:animations:completion:] + 110
24 UIKit 0x03813b71 -[_UIPopoverAnimationController animateTransition:] + 384
25 UIKit 0x03550a8c __56-[UIPresentationController runTransitionForCurrentState]_block_invoke + 2315
26 UIKit 0x0358531b __40+[UIViewController _scheduleTransition:]_block_invoke + 18
27 UIKit 0x0343e862 ___afterCACommitHandler_block_invoke + 15
28 UIKit 0x0343e80d _applyBlockToCFArrayCopiedToStack + 415
29 UIKit 0x0343e622 _afterCACommitHandler + 549
30 CoreFoundation 0x0515086e __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 30
31 CoreFoundation 0x051507b0 __CFRunLoopDoObservers + 400
32 CoreFoundation 0x051461ea __CFRunLoopRun + 1226
33 CoreFoundation 0x05145a5b CFRunLoopRunSpecific + 443
34 CoreFoundation 0x0514588b CFRunLoopRunInMode + 123
35 GraphicsServices 0x05c1a2c9 GSEventRunModal + 192
36 GraphicsServices 0x05c1a106 GSEventRun + 104
37 UIKit 0x03414106 UIApplicationMain + 1526
38 MyAppName 0x000c841d main + 77
39 libdyld.dylib 0x057d5ac9 start + 1</code>

My App crash on iPad before even application:didFinishLaunchingWithOptions:

My app is crashing with the following crashlog when ran on ipad.
It just work fine on iphone devices.
As you might notice, it crash while trying to setup the window. I have searched everywhere but don't see such an issue in any other topic.
Thanks for you help.
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** setObjectForKey: object cannot be nil (key: NSParagraphStyle)'
*** First throw call stack:
(
0 CoreFoundation 0x000000010e38ff35 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x000000010e028bb7 objc_exception_throw + 45
2 CoreFoundation 0x000000010e296998 -[__NSDictionaryM setObject:forKey:] + 968
3 UIKit 0x000000010ca99d2d -[UILabel _setLineBreakMode:] + 529
4 UIKit 0x000000010cb7a572 -[UIButtonLabel setLineBreakMode:] + 93
5 UIKit 0x000000010cb86e5c -[UIButton _setupTitleViewRequestingLayout:] + 308
6 UIKit 0x000000010cb7ed15 -[UIButton titleLabel] + 51
7 UIKit 0x000000010cd3c6d8 -[UIZoomViewController loadView] + 476
8 UIKit 0x000000010c9f67f9 -[UIViewController loadViewIfRequired] + 75
9 UIKit 0x000000010c9f6c8e -[UIViewController view] + 27
10 UIKit 0x000000010cd3bfa4 -[UIZoomViewController init] + 78
11 UIKit 0x000000010cd39eeb -[UIClassicController _setupWindow] + 544
12 UIKit 0x000000010cd39b7c +[UIClassicController sharedClassicController] + 140
13 UIKit 0x000000010c8e47dd -[UIApplication _handleApplicationActivationWithScene:transitionContext:completion:] + 666
14 UIKit 0x000000010c8e42ae __88-[UIApplication _handleApplicationLifecycleEventWithScene:transitionContext:completion:]_block_invoke + 138
15 UIKit 0x000000010c8e4215 -[UIApplication _handleApplicationLifecycleEventWithScene:transitionContext:completion:] + 349
16 UIKit 0x000000010c8cf31a -[UIApplication scene:didUpdateWithDiff:transitionContext:completion:] + 486
17 UIKit 0x000000010c8cedb8 -[UIApplication workspace:didCreateScene:withTransitionContext:completion:] + 336
18 FrontBoardServices 0x000000011064f612 __56-[FBSWorkspace client:handleCreateScene:withCompletion:]_block_invoke_2 + 265
19 FrontBoardServices 0x000000011065e2a3 __31-[FBSSerialQueue performAsync:]_block_invoke + 16
20 CoreFoundation 0x000000010e2c553c __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ + 12
21 CoreFoundation 0x000000010e2bb285 __CFRunLoopDoBlocks + 341
22 CoreFoundation 0x000000010e2bb045 __CFRunLoopRun + 2389
23 CoreFoundation 0x000000010e2ba486 CFRunLoopRunSpecific + 470
24 UIKit 0x000000010c8ce669 -[UIApplication _run] + 413
25 UIKit 0x000000010c8d1420 UIApplicationMain + 1282
26 Edyn 0x0000000109704323 main + 115
27 libdyld.dylib 0x000000010ebd2145 start + 1
28 ??? 0x0000000000000001 0x0 + 1
)
Edit 1
The problem is more complicated than I thought. Here is what I have done.
Implemented method swizzling around [UIButtonLabel setLineBreakMode:] so that I can see what is causing to use nil for the LineBreakMode. I found out that if lineBreakMode is set to something else than NSLineBreakByWordWrapping it ultimately crash.
To temporary make it work I am forcing the lineBreakMode to NSLineBreakByWordWrapping which is not a big deal in this case because the label is never seens in my app.
Edit 2
After fixing the issue with lineBreakMode, I am now getting the same issue but this time with [UILabel setShadow:].
Note that it crash on label where I didn't change anything to the shadow attributes (color, offset or blurRadius).
I also get the same issue but this time with paragraphStyle
Which mean I can't definitely not keep using this approach as it seems to be something broken in what's happening.
Edit 3
When I change the deployment target of my app to universal, I don't have any of the above issues.
I was overriding those two functions in a category and guess what? those function seems to be called by ios even before you get control of the app in your AppDelegate. And for some reason on ipad this return nil.
Removing the category fixed the problem.
+ (id)systemFontOfSize:(CGFloat)sz {
return [UIFont fontWithName:#"HelveticaNeue-Regular" size:sz];
}
+ (id)boldSystemFontOfSize:(CGFloat)sz {
return [UIFont fontWithName:#"HelveticaNeue-Bold" size:sz];
}

App crashing with error: -[NSNull length]: unrecognized selector sent to instance

This line [self.label setFont:[MyUtilityClass fontWithSize:13.0f]]; of code is giving me the -[NSNull length]: crash. label as many of you guys can guess is a UILabel. The only logical explanation I can think of is UILabel text is null. I will post my utility class below just in case it helps.
MyUtilityClass
+ (UIFont *) fontWithSize : (CGFloat) size
{
UIFont *font = [UIFont fontWithName:#"Roboto-Regular" size:size];
return font;
}
edit: This is the error message I've received. I can copy and paste the raw data if you need me to. This is a crash a user received according to crashlytics.
Fatal Exception: NSInvalidArgumentException
-[NSNull length]: unrecognized selector sent to instance 0x378e23f0
This is the raw data of the crash.
Thread : Fatal Exception: NSInvalidArgumentException
0 CoreFoundation 0x297c3c1f __exceptionPreprocess + 126
1 libobjc.A.dylib 0x36f97c8b objc_exception_throw + 38
2 CoreFoundation 0x297c9039 __methodDescriptionForSelector
3 CoreFoundation 0x297c6f57 ___forwarding___ + 714
4 CoreFoundation 0x296f8df8 _CF_forwarding_prep_0 + 24
5 UIKit 0x2cc8b1b5 -[UILabel _setFont:] + 100
6 MyApp 0x00137c29 -[MyViewController initUI] (MyViewController.m:90)
7 MyApp 0x0013765b -[MyViewController viewDidLoad] (MyViewController.m:51)
8 UIKit 0x2cc82f8f -[UIViewController loadViewIfRequired] + 602
9 UIKit 0x2cd2cd95 -[UINavigationController _layoutViewController:] + 32
10 UIKit 0x2cd2ccbd -[UINavigationController _updateScrollViewFromViewController:toViewController:] + 228
11 UIKit 0x2cd2c253 -[UINavigationController _startTransition:fromViewController:toViewController:] + 74
12 UIKit 0x2cd2bf83 -[UINavigationController _startDeferredTransitionIfNeeded:] + 578
13 UIKit 0x2cd2bced -[UINavigationController __viewWillLayoutSubviews] + 44
14 UIKit 0x2cd2bc81 -[UILayoutContainerView layoutSubviews] + 184
15 UIKit 0x2cc804d7 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 514
16 QuartzCore 0x2c6a8a0d -[CALayer layoutSublayers] + 136
17 QuartzCore 0x2c6a43e5 CA::Layer::layout_if_needed(CA::Transaction*) + 360
18 QuartzCore 0x2c6a426d CA::Layer::layout_and_display_if_needed(CA::Transaction*) + 16
19 QuartzCore 0x2c6a3c51 CA::Context::commit_transaction(CA::Transaction*) + 224
20 QuartzCore 0x2c6a3a55 CA::Transaction::commit() + 324
21 UIKit 0x2cc78965 _afterCACommitHandler + 132
22 CoreFoundation 0x2978a3b5 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 20
23 CoreFoundation 0x29787a73 __CFRunLoopDoObservers + 278
24 CoreFoundation 0x29787e7b __CFRunLoopRun + 914
25 CoreFoundation 0x296d6211 CFRunLoopRunSpecific + 476
26 CoreFoundation 0x296d6023 CFRunLoopRunInMode + 106
27 GraphicsServices 0x30a8f0a9 GSEventRunModal + 136
28 UIKit 0x2cce21d1 UIApplicationMain + 1440
29 MyApp 0x000a07e7 main (main.m:16)
30 libdyld.dylib 0x37517aaf start + 2
It's very likely that you are trying to get the length of what you think is an NSString but is actually NSNull.
I got this issue with my code & resolved it by using system fonts. The case was it couldn't load the font which I had specified into the code. Try & let me know if it help.
Happy Coding, cheers,
Ratneshwar

Application crash after updated to IOS7

I have updated my app to IOS7 and now I have very strange issue.
When I start app it start to do what it suppose to do and after 3-5 minutes app stops to work. But not completely. It stops to send notifications, track location etc.
And if I try to make some action I get this in console:
*** First throw call stack:
(
0 CoreFoundation 0x0305f5e4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x0276e8b6 objc_exception_throw + 44
2 CoreFoundation 0x0305f3bb +[NSException raise:format:] + 139
3 UIKit 0x0157465c -[UINib instantiateWithOwner:options:] + 951
4 UIKit 0x013e6c95 -[UIViewController _loadViewFromNibNamed:bundle:] + 280
5 UIKit 0x013e743d -[UIViewController loadView] + 302
6 UIKit 0x013e773e -[UIViewController loadViewIfRequired] + 78
7 UIKit 0x0140d1a5 -[UINavigationController _layoutViewController:] + 39
8 UIKit 0x0140d6bb -[UINavigationController _updateScrollViewFromViewController:toViewController:] + 235
9 UIKit 0x0140d7b3 -[UINavigationController _startTransition:fromViewController:toViewController:] + 78
10 UIKit 0x0140e72c -[UINavigationController _startDeferredTransitionIfNeeded:] + 645
11 UIKit 0x0140f349 -[UINavigationController __viewWillLayoutSubviews] + 57
12 UIKit 0x0154839d -[UILayoutContainerView layoutSubviews] + 213
13 UIKit 0x0cf0656f -[UILayoutContainerViewAccessibility(SafeCategory) layoutSubviews] + 50
14 UIKit 0x0133edd7 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 355
15 libobjc.A.dylib 0x0278081f -[NSObject performSelector:withObject:] + 70
16 QuartzCore 0x00ef972a -[CALayer layoutSublayers] + 148
17 QuartzCore 0x00eed514 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 380
18 QuartzCore 0x00eed380 _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 26
19 QuartzCore 0x00e55156 _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 294
20 QuartzCore 0x00e564e1 _ZN2CA11Transaction6commitEv + 393
21 QuartzCore 0x00f12870 +[CATransaction flush] + 52
22 UIKit 0x012f0979 _afterCACommitHandler + 131
23 CoreFoundation 0x0302753e __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 30
24 CoreFoundation 0x0302748f __CFRunLoopDoObservers + 399
25 CoreFoundation 0x030053b4 __CFRunLoopRun + 1076
26 CoreFoundation 0x03004b33 CFRunLoopRunSpecific + 467
27 CoreFoundation 0x0300494b CFRunLoopRunInMode + 123
28 GraphicsServices 0x03ce89d7 GSEventRunModal + 192
29 GraphicsServices 0x03ce87fe GSEventRun + 104
30 UIKit 0x012d494b UIApplicationMain + 1225
31 MyApp 0x0000759d main + 141
32 libdyld.dylib 0x02c53725 start + 0
33 ??? 0x00000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
Any idea what is this?
App works fine in IOS6.
Create an exception breakpoint in Xcode that stops on all exceptions. Then the debugger will stop when that exception is raised. It looks like it is in
[UINib instantiateWithOwner:options:]
But I can't tell if you are calling that or the system.
See here for a related issue:
Terminating app due to uncaught exception 'NSUnknownKeyException'
I must test this on real phone just to be sure.
I have a piece of code that refreshes some labels in the view every X seconds.
It works fine until IOS7. On IOS7 app crashes after 3 minutes and I get the error from the question.
Every time I refresh labels in the view I was opened a new connection to sqlite to get data.
In IOS7 I get error so I made one instance of data access class and init it only in viewDidLoad() and now it works fine.
If after test I confirm that I am right I will definitely make singleton pattern of my data access class.

Resources