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];
}
Related
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:
I'm a beginner working through Ray Wenderlich's Swift tutorial, Part 2.
The final code for the lesson (and with which I'm receiving the error) is here: http://cdn5.raywenderlich.com/wp-content/uploads/2014/06/TipCalculator-Demo4.zip
When I build the app through Xcode 6.3.2 and run it on the iOS simulator (iPhone 6), I get the error message below (sorry for the poor formatting).
I did a search on both Google and StackOverflow, seems like people often run into similar errors but are able to fix it by going to the view controller, checking the Connections Inspector, and fixing any of the connections that are flagged (e.g., an object being connected to no longer exists).
Note: I don't have any flags in my Connections Inspector -- everything seems fine there, including the connection between resultsTextView and Text View object in the Storyboard (please see attached photo)
Please let me know how to solve this - thanks.
---------See Connection Inspector on far right - looks fine!-----------
http://i.imgur.com/X6eA05F.png
---------Error message---------
2015-06-05 17:07:39.866 TipCalculator[4848:128801] * Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[ setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key resultsTextView.'
* First throw call stack:
(
0 CoreFoundation 0x0000000100216c65 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x0000000101d81bb7 objc_exception_throw + 45
2 CoreFoundation 0x00000001002168a9 -[NSException raise] + 9
3 Foundation 0x0000000100634b53 -[NSObject(NSKeyValueCoding) setValue:forKey:] + 259
4 CoreFoundation 0x000000010015ed50 -[NSArray makeObjectsPerformSelector:] + 224
5 UIKit 0x0000000100d8d52b -[UINib instantiateWithOwner:options:] + 1506
6 UIKit 0x0000000100be5718 -[UIViewController _loadViewFromNibNamed:bundle:] + 242
7 UIKit 0x0000000100be5d08 -[UIViewController loadView] + 109
8 UIKit 0x0000000100be5f79 -[UIViewController loadViewIfRequired] + 75
9 UIKit 0x0000000100c1601b -[UINavigationController _layoutViewController:] + 44
10 UIKit 0x0000000100c16565 -[UINavigationController _updateScrollViewFromViewController:toViewController:] + 216
11 UIKit 0x0000000100c16664 -[UINavigationController _startTransition:fromViewController:toViewController:] + 92
12 UIKit 0x0000000100c17448 -[UINavigationController _startDeferredTransitionIfNeeded:] + 523
13 UIKit 0x0000000100c17f0e -[UINavigationController __viewWillLayoutSubviews] + 43
14 UIKit 0x0000000100d62715 -[UILayoutContainerView layoutSubviews] + 202
15 UIKit 0x0000000100b35a2b -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 536
16 QuartzCore 0x0000000104916ec2 -[CALayer layoutSublayers] + 146
17 QuartzCore 0x000000010490b6d6 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 380
18 QuartzCore 0x000000010490b546 _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 24
19 QuartzCore 0x0000000104877886 _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 242
20 QuartzCore 0x0000000104878a3a _ZN2CA11Transaction6commitEv + 462
21 UIKit 0x0000000100ab3a2d -[UIApplication _reportMainSceneUpdateFinished:] + 44
22 UIKit 0x0000000100ab46f1 -[UIApplication _runWithMainScene:transitionContext:completion:] + 2648
23 UIKit 0x0000000100ab30d5 -[UIApplication workspaceDidEndTransaction:] + 179
24 FrontBoardServices 0x00000001038915e5 __31-[FBSSerialQueue performAsync:]_block_invoke_2 + 21
25 CoreFoundation 0x000000010014a41c __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ + 12
26 CoreFoundation 0x0000000100140165 __CFRunLoopDoBlocks + 341
27 CoreFoundation 0x000000010013f947 __CFRunLoopRun + 887
28 CoreFoundation 0x000000010013f366 CFRunLoopRunSpecific + 470
29 UIKit 0x0000000100ab2b42 -[UIApplication _run] + 413
30 UIKit 0x0000000100ab5900 UIApplicationMain + 1282
31 TipCalculator 0x000000010002c177 main + 135
32 libdyld.dylib 0x00000001024d9145 start + 1
33 ??? 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
Make sure you follow those steps correctly:
Open Main.storyboard and select your View Controller in the Document
Outline. Open the Connections Inspector (6th tab), and you will see
all of the properties you created listed in the Outlets section.
021_ConnectionsInspector You’ll notice a small circle to the right of
resultsTextView. Control-drag from that button down to the text view
below the Calculate button, and release to connect your Swift property
to this view.
I believe you are missing the #IBOutlet that is create in this step
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?
My app is crashing upon running it with the following debug:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'NSConcreteMutableAttributedString initWithString:attributes:: nil value'
*** First throw call stack:
(
0 CoreFoundation 0x0000000102a83495 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x00000001027e299e objc_exception_throw + 43
2 CoreFoundation 0x0000000102a832ad +[NSException raise:format:] + 205
3 Foundation 0x00000001023d993e -[NSConcreteMutableAttributedString initWithString:attributes:] + 129
4 myApp 0x0000000100006da5 -[WelcomeViewController viewDidLoad] + 373
5 UIKit 0x000000010148559e -[UIViewController loadViewIfRequired] + 562
6 UIKit 0x0000000101485777 -[UIViewController view] + 29
7 UIKit 0x00000001017902e2 -[UIClientRotationContext initWithClient:toOrientation:duration:andWindow:] + 390
8 UIKit 0x00000001013cbffa -[UIWindow _setRotatableClient:toOrientation:updateStatusBar:duration:force:isRotating:] + 1109
9 UIKit 0x00000001013cbb9f -[UIWindow _setRotatableClient:toOrientation:updateStatusBar:duration:force:] + 36
10 UIKit 0x00000001013cbaef -[UIWindow _setRotatableViewOrientation:updateStatusBar:duration:force:] + 101
11 UIKit 0x00000001013cadfe -[UIWindow _updateToInterfaceOrientation:duration:force:] + 377
12 UIKit 0x000000010148970a -[UIViewController _tryBecomeRootViewControllerInWindow:] + 147
13 UIKit 0x00000001013c5b1b -[UIWindow addRootViewControllerViewIfPossible] + 490
14 UIKit 0x00000001013c5c70 -[UIWindow _setHidden:forced:] + 282
15 UIKit 0x00000001013ceffa -[UIWindow makeKeyAndVisible] + 51
16 UIKit 0x000000010138ac98 -[UIApplication _callInitializationDelegatesForURL:payload:suspended:] + 1788
17 UIKit 0x000000010138ea0c -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 660
18 UIKit 0x000000010139fd4c -[UIApplication handleEvent:withNewEvent:] + 3189
19 UIKit 0x00000001013a0216 -[UIApplication sendEvent:] + 79
20 UIKit 0x0000000101390086 _UIApplicationHandleEvent + 578
21 GraphicsServices 0x00000001047dd71a _PurpleEventCallback + 762
22 GraphicsServices 0x00000001047dd1e1 PurpleEventCallback + 35
23 CoreFoundation 0x0000000102a05679 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 41
24 CoreFoundation 0x0000000102a0544e __CFRunLoopDoSource1 + 478
25 CoreFoundation 0x0000000102a2e903 __CFRunLoopRun + 1939
26 CoreFoundation 0x0000000102a2dd83 CFRunLoopRunSpecific + 467
27 UIKit 0x000000010138e2e1 -[UIApplication _run] + 609
28 UIKit 0x000000010138fe33 UIApplicationMain + 1010
29 myApp 0x0000000100006b03 main + 115
30 libdyld.dylib 0x00000001033c25fd start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
The problem is that I know for a fact I never used NSConcreteMutableAttributedString I have checked and double checked my code to see if maybe I am missing something but I keep coming up blank, any ideas as to what can be done to fix this problem?
Update
I added an exception breakpoint which told me that the following line was causing my app to crash:
NSMutableAttributedString *thirdGreetingAttr = [[NSMutableAttributedString alloc] initWithString:thirdGreeting attributes:secondGreetingAttrs19];
self.welcomeUserLabel.attributedText = thirdGreetingAttr;
"Ok, odd" I think to myself, this was working just fine 2 weeks ago when I last touched this project, This is the complete code block:
NSDictionary *secondGreetingAttrs19 = [NSDictionary dictionaryWithObjectsAndKeys:fitnestFontBold, NSFontAttributeName, nil];
NSString *thirdGreeting = currentUser.username;
NSMutableAttributedString *thirdGreetingAttr = [[NSMutableAttributedString alloc] initWithString:thirdGreeting attributes:secondGreetingAttrs19];
self.welcomeUserLabel.attributedText = thirdGreetingAttr;
So I go ahead and comment out the 2 lines that are causing the issue, and the app runs just fine. I un-comment the lines back to how it was originally and to my surprise build runs JUST FINE :/ what??? Anyone know what could have happened here?
UPDATE
As the chosen answer says, I realized that this error was happening because my username property was returning a null value.
make sure your thirdGreeting(NSString *thirdGreeting = currentUser.username; ) is not nil value.
I think the thireGreeting is nil, you should change to
NSString *thirdGreeting = (currentUser.username.length>0) ? currentUser.username.length : #"";
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.