crash with insertObject:atIndex: object cannot be nil but no array - ios

I'm fighting with a crash in my app but I can't find where it happens.
I'm working with last version of MZFormSheetController. When I receive a remote push I present a basic MZFormSheetController, it was working nice but from one day to the other it starts crashing with a weird stack trace :
Fatal Exception: NSInvalidArgumentException
*** -[__NSArrayM insertObject:atIndex:]: object cannot be nil
Thread : Fatal Exception: NSInvalidArgumentException
0 CoreFoundation 0x2bfc2fef __exceptionPreprocess + 126
1 libobjc.A.dylib 0x3a274c8b objc_exception_throw + 38
2 CoreFoundation 0x2bedcefb -[__NSArrayM insertObject:atIndex:] + 638
3 UIKit 0x2fb6289f __workaround10030904InvokeWithTarget_block_invoke + 14
4 UIKit 0x2f8b2ab1 +[UIView _performSystemAppearanceModifications:] + 32
5 UIKit 0x2f780639 workaround10030904InvokeWithTarget + 704
6 UIKit 0x2fb5ff3b applyInvocationsToTarget + 1242
7 UIKit 0x2f6bdd8f +[_UIAppearance _applyInvocationsTo:window:matchingSelector:] + 1262
8 UIKit 0x2f6bd89b +[_UIAppearance _applyInvocationsTo:window:] + 30
9 UIKit 0x2f8bc353 __88-[UIView(Internal) _performUpdatesForPossibleChangesOfIdiom:orScreen:traverseHierarchy:]_block_invoke + 54
10 UIKit 0x2f8bc2cb -[UIView(Internal) _performUpdatesForPossibleChangesOfIdiom:orScreen:traverseHierarchy:] + 262
11 UIKit 0x2f61cf07 -[UIView(Internal) _didChangeFromIdiom:onScreen:traverseHierarchy:] + 30
12 UIKit 0x2f633f0f -[UIScrollView _didChangeFromIdiom:onScreen:traverseHierarchy:] + 46
13 UIKit 0x2f8bc1b7 -[UIView(Internal) _didChangeFromIdiomOnScreen:traverseHierarchy:] + 138
14 UIKit 0x2f61497d -[UIView(Internal) _didMoveFromWindow:toWindow:] + 1316
15 UIKit 0x2f633dfb -[UIScrollView _didMoveFromWindow:toWindow:] + 50
16 UIKit 0x2f6146fb -[UIView(Internal) _didMoveFromWindow:toWindow:] + 674
17 UIKit 0x2f6146fb -[UIView(Internal) _didMoveFromWindow:toWindow:] + 674
18 UIKit 0x2f613fa7 __45-[UIView(Hierarchy) _postMovedFromSuperview:]_block_invoke + 114
19 UIKit 0x2f613ec1 -[UIView(Hierarchy) _postMovedFromSuperview:] + 428
20 UIKit 0x2f61e72b -[UIView(Internal) _addSubview:positioned:relativeTo:] + 1498
21 UIKit 0x2f61e14b -[UIView(Hierarchy) addSubview:] + 30
22 UIKit 0x2f61db69 -[UIWindow addRootViewControllerViewIfPossible] + 432
23 UIKit 0x2f61b3a1 -[UIWindow _setHidden:forced:] + 272
24 UIKit 0x2f6864a1 -[UIWindow makeKeyAndVisible] + 48
25 Project 0x000f382d -[MZFormSheetController presentAnimated:completionHandler:] (MZFormSheetController.m:509)
26 Project 0x0021b879 __60+[ARDPopupManager showFormsheet:animated:completionHandler:]_block_invoke_2 (ARDPopupManager.m:46)
27 libdispatch.dylib 0x3a7e9ecd _dispatch_barrier_sync_f_slow_invoke + 372
28 libdispatch.dylib 0x3a7df2cf _dispatch_client_callout + 22
29 libdispatch.dylib 0x3a7e2d2f _dispatch_main_queue_callback_4CF + 1330
30 CoreFoundation 0x2bf88609 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 8
31 CoreFoundation 0x2bf86d09 __CFRunLoopRun + 1512
32 CoreFoundation 0x2bed3201 CFRunLoopRunSpecific + 476
33 CoreFoundation 0x2bed3013 CFRunLoopRunInMode + 106
34 GraphicsServices 0x337b2201 GSEventRunModal + 136
35 UIKit 0x2f677a59 UIApplicationMain + 1440
36 Project 0x0007a88d main (main.m:14)
37 libdyld.dylib 0x3a800aaf start + 2
Of course I understand the crash but the exception breakpoint stops at this line :
[self.formSheetWindow makeKeyAndVisible];
In MZFormSheetController library and the MZFormSheetController is presented from my code like :
[formsheet presentAnimated:animated completionHandler:nil];
I added an All Exception Breakpoint but it does not point to an addObject: or insertObject:atIndex: method. Maybe it is elsewhere but I can't figure it out. I can't find the NSArray causing this crash.

Finally found : in the view controller presented in form sheet controller I added an UITextView and in my AppDelegate I wrote [[UITextView appearance] setKeyboardAppearance:UIKeyboardAppearanceDark]; and it crashes when I present the UITextView. So I had to set keyboard appearance individually on each UITextView instances storyboard or code...

I think it will solve problem.
YourViewController *objVc = [[YourViewController alloc] init]; // or you can use initWithNib
// Your remaining code
MZFormSheetController *formSheet = [[MZFormSheetController alloc]initWithViewController:objVc];
formSheet.transitionStyle = MZFormSheetTransitionStyleSlideFromBottom; //try different style
formSheet.presentedFormSheetSize = CGSizeMake(320, self.view.frame.size.height);
formSheet.willPresentCompletionHandler = ^(UIViewController *presentedFSViewController)
{
presentedFSViewController.view.autoresizingMask = presentedFSViewController.view.autoresizingMask | UIViewAutoresizingFlexibleWidth;
};
formSheet.shouldCenterVertically = YES;
[formSheet presentAnimated:YES completionHandler:^(UIViewController *presentedFSViewController){ }];

Related

How to find the line of the crash?

I have some beginner trouble using xCode. Each time the app crash I find it hard to find the problem as I don't understand the log currently I seem to have a problem with a Array. I think it is a Array of which I deleted the class where it was in.
I would like to know how I should read this log :
2014-05-02 10:49:32.808 myCompany[2793:60b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSArrayM insertObject:atIndex:]: object cannot be nil'
*** First throw call stack:
(
0 CoreFoundation 0x017f21e4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x015718e5 objc_exception_throw + 44
2 CoreFoundation 0x017a4abc -[__NSArrayM insertObject:atIndex:] + 844
3 CoreFoundation 0x017a4760 -[__NSArrayM addObject:] + 64
4 UIKit 0x00794a4b PushNextClassForSettingIMP + 383
5 UIKit 0x00794838 __workaround10030904InvokeWithTarget_block_invoke + 29
6 UIKit 0x00284413 +[UIView _performCustomizableAppearanceModifications:] + 26
7 UIKit 0x00794810 workaround10030904InvokeWithTarget + 940
8 UIKit 0x0078ee71 +[_UIAppearance _applyInvocationsTo:window:matchingSelector:] + 3779
9 UIKit 0x0078f633 +[_UIAppearance _applyInvocationsTo:window:] + 55
10 UIKit 0x0029b5a3 -[UIView(Internal) _applyAppearanceInvocations] + 270
11 UIKit 0x0029c002 __88-[UIView(Internal) _performUpdatesForPossibleChangesOfIdiom:orScreen:traverseHierarchy:]_block_invoke + 65
12 UIKit 0x0029bf8f -[UIView(Internal) _performUpdatesForPossibleChangesOfIdiom:orScreen:traverseHierarchy:] + 204
13 UIKit 0x0029bebe -[UIView(Internal) _didChangeFromIdiom:onScreen:traverseHierarchy:] + 52
14 UIKit 0x003f44b7 -[UILabel(_UIAccessibilityButtonShapesSupportInternal) _didChangeFromIdiom:onScreen:traverseHierarchy:] + 73
15 UIKit 0x004ed776 -[UITabBarButtonLabel _didChangeFromIdiom:onScreen:traverseHierarchy:] + 73
16 UIKit 0x0029be82 -[UIView(Internal) _didChangeFromIdiomOnScreen:traverseHierarchy:] + 172
17 UIKit 0x0029b466 -[UIView(Internal) _didMoveFromWindow:toWindow:] + 1624
18 UIKit 0x0029b109 -[UIView(Internal) _didMoveFromWindow:toWindow:] + 763
19 UIKit 0x00334458 -[UIControl _didMoveFromWindow:toWindow:] + 65
20 UIKit 0x0029b109 -[UIView(Internal) _didMoveFromWindow:toWindow:] + 763
21 UIKit 0x004fad59 -[UITabBar(UITabBarPrivate) _didMoveFromWindow:toWindow:] + 65
22 UIKit 0x0029b109 -[UIView(Internal) _didMoveFromWindow:toWindow:] + 763
23 UIKit 0x0029296f __45-[UIView(Hierarchy) _postMovedFromSuperview:]_block_invoke + 158
24 UIKit 0x002927fb -[UIView(Hierarchy) _postMovedFromSuperview:] + 260
25 UIKit 0x0029ddd4 -[UIView(Internal) _addSubview:positioned:relativeTo:] + 1875
26 UIKit 0x00290dba -[UIView(Hierarchy) addSubview:] + 56
27 UIKit 0x00270406 -[UIWindow addRootViewControllerViewIfPossible] + 481
28 UIKit 0x002705ef -[UIWindow _setHidden:forced:] + 312
29 UIKit 0x0027086b -[UIWindow _orderFrontWithoutMakingKey] + 49
30 UIKit 0x0027b3c8 -[UIWindow makeKeyAndVisible] + 65
31 UIKit 0x0022bbc0 -[UIApplication _callInitializationDelegatesForURL:payload:suspended:] + 2097
32 UIKit 0x00230667 -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 824
33 UIKit 0x00244f92 -[UIApplication handleEvent:withNewEvent:] + 3517
34 UIKit 0x00245555 -[UIApplication sendEvent:] + 85
35 UIKit 0x00232250 _UIApplicationHandleEvent + 683
36 GraphicsServices 0x037e7f02 _PurpleEventCallback + 776
37 GraphicsServices 0x037e7a0d PurpleEventCallback + 46
38 CoreFoundation 0x0176dca5 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 53
39 CoreFoundation 0x0176d9db __CFRunLoopDoSource1 + 523
40 CoreFoundation 0x0179868c __CFRunLoopRun + 2156
41 CoreFoundation 0x017979d3 CFRunLoopRunSpecific + 467
42 CoreFoundation 0x017977eb CFRunLoopRunInMode + 123
43 UIKit 0x0022fd9c -[UIApplication _run] + 840
44 UIKit 0x00231f9b UIApplicationMain + 1225
45 myCompany 0x000043fd main + 141
46 libdyld.dylib 0x01e39701 start + 1
)
EDIT :
this caused the problem :
UIImage *tabBackground = [[UIImage imageNamed:#"image.PNG"]
resizableImageWithCapInsets:UIEdgeInsetsMake(0, 0, 0, 0)];
[[UITabBarItem appearance] setImage:tabBackground];
Still I don't understand why it can't just display the line of error like android. I found this by comment lining
I think you must follow up this tutorial, clearly mentioning about this
http://www.raywenderlich.com/10209/my-app-crashed-now-what-part-1
According to your log details,
You are trying to create array with nil objects.
Trying to insert nil object to array
both above will crash the app.
Enable zombies
Product->Edit Scheme->Diagnostics-> Click Enable Zombie Objects
You forgot to add nil at last index in array creation.
like this
NSArray *array = [NSArray arrayWithObjects:#"1",#"2"]; 
But it should be
NSArray *array = [NSArray arrayWithObjects:#"1",#"2",nil]; 
But If you are using NSMutableArray and add objects,then u should valid to nil condition like below.
if (myObjectToBeAddedToArray!=nil) {
[arrayMutable addObject:myObjectToBeAddedToArray];
}

iOS 7.1 update crash when switching between uitextfields with reason setObjectForKey: object cannot be nil (key: NSShadow)

We have a failry complex mobile application that uses a static table view for input. With the update to ios 7.1 we are now getting a crash after a user goes through a few text fields without entering information, then enters something and moves to the next text field. The crash is
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: ' setObjectForKey: object cannot be nil (key: NSShadow)'
with this stack trace:
* First throw call stack: (
0 CoreFoundation 0x000000010342b495 exceptionPreprocess + 165
1 libobjc.A.dylib 0x000000010318a99e objc_exception_throw + 43
2 CoreFoundation 0x00000001034aa544 -[NSDictionaryM setObject:forKey:] + 916
3 UIKit 0x0000000101eb877c -[UILabel setShadow:] + 339
4 UIKit 0x0000000101eb88b5 -[UILabel setShadowColor:] + 100
5 CoreFoundation 0x0000000103420f1c invoking + 140
6 CoreFoundation 0x00000001034b0e84 -[NSInvocation invokeUsingIMP:] + 212
7 UIKit 0x00000001021f0b4d workaround10030904InvokeWithTarget_block_invoke + 88
8 UIKit 0x0000000101d7eecb +[UIView _performCustomizableAppearanceModifications:] + 33
9 UIKit 0x00000001021f0ae3 workaround10030904InvokeWithTarget + 938
10 UIKit 0x00000001021ebfc9 +[_UIAppearance _applyInvocationsTo:window:matchingSelector:] + 3482
11 UIKit 0x0000000101d938fa 88-[UIView(Internal) performUpdatesForPossibleChangesOfIdiom:orScreen:traverseHierarchy:]block_invoke + 63
12 UIKit 0x0000000101d93885 -[UIView(Internal) _performUpdatesForPossibleChangesOfIdiom:orScreen:traverseHierarchy:] + 230
13 UIKit 0x0000000101d92e2c -[UIView(Internal) _didMoveFromWindow:toWindow:] + 1369
14 UIKit 0x0000000101d8b996 45-[UIView(Hierarchy) postMovedFromSuperview:]_block_invoke + 128
15 UIKit 0x0000000101d8b85c -[UIView(Hierarchy) _postMovedFromSuperview:] + 276
16 UIKit 0x0000000101d952ac -[UIView(Internal) _addSubview:positioned:relativeTo:] + 1508
17 UIKit 0x000000010237d922 -[UITextField willDetachFieldEditor:] + 96
18 UIKit 0x0000000101e1b48e -[UIFieldEditor becomeFieldEditorForView:] + 236
19 UIKit 0x0000000102375497 -[UITextField _resignFirstResponder] + 197
20 UIKit 0x0000000101e6b212 -[UIResponder resignFirstResponder] + 128
21 UIKit 0x00000001023752db -[UITextField resignFirstResponder] + 114
22 UIKit 0x0000000101e6b011 -[UIResponder becomeFirstResponder] + 297
23 UIKit 0x0000000101d8b673 -[UIView(Hierarchy) becomeFirstResponder] + 99
24 UIKit 0x0000000102374b08 -[UITextField becomeFirstResponder] + 51
25 UIKit 0x0000000102067d01 -[UITextInteractionAssistant(UITextInteractionAssistant_Internal) setFirstResponderIfNecessary] + 187
26 UIKit 0x0000000102069b30 -[UITextInteractionAssistant(UITextInteractionAssistant_Internal) oneFingerTap:] + 1768
27 UIKit 0x000000010205ffc2 _UIGestureRecognizerSendActions + 188
28 UIKit 0x000000010205ef28 -[UIGestureRecognizer _updateGestureWithEvent:buttonEvent:] + 357
29 UIKit 0x00000001020632d9 UIGestureRecognizerUpdate_block_invoke + 53
30 UIKit 0x0000000102063261 _UIGestureRecognizerRemoveObjectsFromArrayAndApplyBlocks + 257
31 UIKit 0x000000010205b337 _UIGestureRecognizerUpdate + 93
32 UIKit 0x0000000101d6fa15 -[UIWindow _sendGesturesForEvent:] + 928
33 UIKit 0x0000000101d706d4 -[UIWindow sendEvent:] + 909
34 UIKit 0x0000000101d4829a -[UIApplication sendEvent:] + 211
35 UIKit 0x0000000101d35aed _UIApplicationHandleEventQueue + 9579
36 CoreFoundation 0x00000001033bad21 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION + 17
37 CoreFoundation 0x00000001033ba5f2 CFRunLoopDoSources0 + 242
38 CoreFoundation 0x00000001033d646f CFRunLoopRun + 767
39 CoreFoundation 0x00000001033d5d83 CFRunLoopRunSpecific + 467
40 GraphicsServices 0x000000010524cf04 GSEventRunModal + 161
41 UIKit 0x0000000101d37e33 UIApplicationMain + 1010
42 Sales Rabbit 0x000000010000c333 main + 115
43 libdyld.dylib 0x0000000103ac35fd start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
As far as I can tell the crash is happening when we call
[curView becomeFirstResponder];
curView is not nil, and is a uitextfield
Any ideas on what to check or help would be greatly appreciated.
So I ended up finding the answer, for some reason someone had written this line of code even though it doesnt seem necessary.
[[UILabel appearance] setShadowColor:[UIColor clearColor]];
And this was causing it to crash, but only in the situation that I described above, not when it was set in the app delegate. It seems like it should be allowed to set a the shadow color to clear, although why you would do this is not apparent to me.

'NSInternalInconsistencyException' - unable to push uitableviewcontroller on uinavigationcontroller ios 6

I am simply pushing a UITableviewController to navigation stack. Code works fine in both iOS 4.3 and 5 but crashes in iOS 6. Exception is:
Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '-[UIViewController _loadViewFromNibNamed:bundle:] loaded the "MenuController" nib but the view outlet was not set.'
I know this exception is raised when view outlet is not set. Outlet is set automatically by IB as you can see in figure, but still the same. What am I doing wrong?
Simple code pushing the controller:
MenuController *menu = [[MenuController alloc] initWithStyle:UITableViewStylePlain];
menu.title = #"Watches";
menu.MenuToBeDisplayed = #"main menu";
[self.navigationController pushViewController:menu animated:YES];
Stack trace is:
0 CoreFoundation 0x01f3e02e __exceptionPreprocess + 206
1 libobjc.A.dylib 0x01a12e7e objc_exception_throw + 44
2 CoreFoundation 0x01f3ddeb +[NSException raise:format:] + 139
3 UIKit 0x00a3af18 -[UIViewController _loadViewFromNibNamed:bundle:] + 505
4 UIKit 0x00a3b418 -[UIViewController loadView] + 302
5 UIKit 0x00b8934e -[UITableViewController loadView] + 80
6 UIKit 0x00a3b648 -[UIViewController loadViewIfRequired] + 73
7 UIKit 0x00a3b882 -[UIViewController view] + 33
8 UIKit 0x00a3bb2a -[UIViewController contentScrollView] + 36
9 UIKit 0x00a52ef5 -[UINavigationController _computeAndApplyScrollContentInsetDeltaForViewController:] + 36
10 UIKit 0x00a52fdb -[UINavigationController _layoutViewController:] + 43
11 UIKit 0x00a53286 -[UINavigationController _updateScrollViewFromViewController:toViewController:] + 254
12 UIKit 0x00a53381 -[UINavigationController _startTransition:fromViewController:toViewController:] + 72
13 UIKit 0x00a53eab -[UINavigationController _startDeferredTransitionIfNeeded:] + 386
14 UIKit 0x00a544a3 -[UINavigationController pushViewController:transition:forceImmediate:] + 1030
15 UIKit 0x00a54098 -[UINavigationController pushViewController:animated:] + 62
16 Tick 0x000e5f02 -[MarketWatchViewController openMenu] + 274
17 libobjc.A.dylib 0x01a26705 -[NSObject performSelector:withObject:withObject:] + 77
18 UIKit 0x0095d920 -[UIApplication sendAction:to:from:forEvent:] + 96
19 UIKit 0x00b99b24 -[UIBarButtonItem(UIInternal) _sendAction:withEvent:] + 139
20 libobjc.A.dylib 0x01a26705 -[NSObject performSelector:withObject:withObject:] + 77
21 UIKit 0x0095d920 -[UIApplication sendAction:to:from:forEvent:] + 96
22 UIKit 0x0095d8b8 -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 61
23 UIKit 0x00a1e671 -[UIControl sendAction:to:forEvent:] + 66
24 UIKit 0x00a1ebcf -[UIControl(Internal) _sendActionsForEvents:withEvent:] + 578
25 UIKit 0x00a1dd38 -[UIControl touchesEnded:withEvent:] + 546
26 UIKit 0x0098d33f -[UIWindow _sendTouchesForEvent:] + 846
27 UIKit 0x0098d552 -[UIWindow sendEvent:] + 273
28 UIKit 0x0096b3aa -[UIApplication sendEvent:] + 436
29 UIKit 0x0095ccf8 _UIApplicationHandleEvent + 9874
30 GraphicsServices 0x0291adf9 _PurpleEventCallback + 339
31 GraphicsServices 0x0291aad0 PurpleEventCallback + 46
32 CoreFoundation 0x01eb3bf5 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 53
33 CoreFoundation 0x01eb3962 __CFRunLoopDoSource1 + 146
34 CoreFoundation 0x01ee4bb6 __CFRunLoopRun + 2118
35 CoreFoundation 0x01ee3f44 CFRunLoopRunSpecific + 276
36 CoreFoundation 0x01ee3e1b CFRunLoopRunInMode + 123
37 GraphicsServices 0x029197e3 GSEventRunModal + 88
38 GraphicsServices 0x02919668 GSEventRun + 104
39 UIKit 0x0095a65c UIApplicationMain + 1211
40 Tick 0x00002dc5 main + 197
41 Tick 0x00002cb5 start + 53
EDIT:
I have removed nib file, and also initWithNibName: method, but I am still getting this stupid exception since yesterday. This will drive me crazy :(
With
MenuController *menu = [[MenuController alloc] initWithStyle:UITableViewStylePlain];
You aren't using your xib file at all becouse for initing contreoller with xib you need to use
initWithNibName:bundle: instead of initWithStyle:
and then set your controller's class on xib like this

Autorotation crash in iOS

I am getting abnormal termination (crash) with the App which I am working with when I am changing the device orientation. I am unable to reproduce it so often (it's not happening always when I am rotating, let's say the chance would be some where around 0.01%), but it's a serious problem. I am attaching an important part of a crash report.
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x6563616e
Crashed Thread: 0
Thread 0 name: Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0 libobjc.A.dylib 0x3233a5b0 objc_msgSend + 16
1 UIKit 0x36297b82 -[UISectionRowData refreshWithSection:tableView:tableViewRowData:] + 1546
2 UIKit 0x3628301e -[UITableViewRowData rectForFooterInSection:] + 310
3 UIKit 0x3628358c -[UITableViewRowData heightForTable] + 48
4 UIKit 0x36283400 -[UITableView(_UITableViewPrivate) _updateContentSize] + 324
5 UIKit 0x362cc8b4 -[UITableView _rectChangedWithNewSize:oldSize:] + 252
6 UIKit 0x362cc544 -[UITableView setFrame:] + 220
7 UIKit 0x362c59c4 -[UIView(Geometry) _applyAutoresizingMaskWithOldSuperviewSize:] + 644
8 UIKit 0x362c572e -[UIView(Geometry) _resizeWithOldSuperviewSize:] + 262
9 UIKit 0x3644eb2a -[UIScrollView _resizeWithOldSuperviewSize:] + 38
10 CoreFoundation 0x35b63aec __NSArrayChunkIterate + 360
11 CoreFoundation 0x35b5ca74 __NSArrayEnumerate + 608
12 CoreFoundation 0x35abeb66 -[NSArray enumerateObjectsWithOptions:usingBlock:] + 58
13 UIKit 0x3627e09e -[UIView(Geometry) resizeSubviewsWithOldSize:] + 114
14 UIKit 0x36263ba2 -[UIView(Geometry) setFrame:] + 414
15 UIKit 0x362c59c4 -[UIView(Geometry) _applyAutoresizingMaskWithOldSuperviewSize:] + 644
16 UIKit 0x362c572e -[UIView(Geometry) _resizeWithOldSuperviewSize:] + 262
17 CoreFoundation 0x35b63aec __NSArrayChunkIterate + 360
18 CoreFoundation 0x35b5ca74 __NSArrayEnumerate + 608
19 CoreFoundation 0x35abeb66 -[NSArray enumerateObjectsWithOptions:usingBlock:] + 58
20 UIKit 0x3627e09e -[UIView(Geometry) resizeSubviewsWithOldSize:] + 114
21 UIKit 0x36263ba2 -[UIView(Geometry) setFrame:] + 414
22 UIKit 0x362a6dc0 -[UIViewControllerWrapperView setFrame:] + 48
23 UIKit 0x362c59c4 -[UIView(Geometry) _applyAutoresizingMaskWithOldSuperviewSize:] + 644
24 UIKit 0x362c572e -[UIView(Geometry) _resizeWithOldSuperviewSize:] + 262
25 CoreFoundation 0x35b63aec __NSArrayChunkIterate + 360
26 CoreFoundation 0x35b5ca74 __NSArrayEnumerate + 608
27 CoreFoundation 0x35abeb66 -[NSArray enumerateObjectsWithOptions:usingBlock:] + 58
28 UIKit 0x3627e09e -[UIView(Geometry) resizeSubviewsWithOldSize:] + 114
29 UIKit 0x36263ba2 -[UIView(Geometry) setFrame:] + 414
30 UIKit 0x362c59c4 -[UIView(Geometry) _applyAutoresizingMaskWithOldSuperviewSize:] + 644
31 UIKit 0x362c572e -[UIView(Geometry) _resizeWithOldSuperviewSize:] + 262
32 CoreFoundation 0x35b63aec __NSArrayChunkIterate + 360
33 CoreFoundation 0x35b5ca74 __NSArrayEnumerate + 608
34 CoreFoundation 0x35abeb66 -[NSArray enumerateObjectsWithOptions:usingBlock:] + 58
35 UIKit 0x3627e09e -[UIView(Geometry) resizeSubviewsWithOldSize:] + 114
36 UIKit 0x362c64ae -[UIView(Geometry) setBounds:] + 430
37 UIKit 0x3634ff32 -[UILayoutContainerView setBounds:] + 58
38 UIKit 0x363edd88 -[UIViewController window:willAnimateRotationToInterfaceOrientation:duration:] + 460
39 UIKit 0x3630e2b0 -[UIWindow _setRotatableClient:toOrientation:updateStatusBar:duration:force:isRotating:] + 3616
40 UIKit 0x3630d482 -[UIWindow _setRotatableClient:toOrientation:updateStatusBar:duration:force:] + 42
41 UIKit 0x3630d40c -[UIWindow _setRotatableViewOrientation:duration:force:] + 64
42 UIKit 0x3644317c __57-[UIWindow _updateToInterfaceOrientation:duration:force:]_block_invoke_0 + 100
43 UIKit 0x362cb676 -[UIWindow _updateToInterfaceOrientation:duration:force:] + 214
44 UIKit 0x362d4d20 -[UIWindow _updateInterfaceOrientationFromDeviceOrientation:] + 176
45 CoreFoundation 0x35ab9034 _CFXNotificationPost + 1424
46 Foundation 0x3721bd8c -[NSNotificationCenter postNotificationName:object:userInfo:] + 68
47 UIKit 0x36268c60 -[UIDevice setOrientation:animated:] + 292
48 UIKit 0x362633d6 -[UIApplication handleEvent:withNewEvent:] + 2954
49 UIKit 0x362626c8 -[UIApplication sendEvent:] + 68
50 UIKit 0x36262116 _UIApplicationHandleEvent + 6150
51 GraphicsServices 0x318885a0 _PurpleEventCallback + 588
52 GraphicsServices 0x318881ce PurpleEventCallback + 30
53 CoreFoundation 0x35b3d170 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 32
54 CoreFoundation 0x35b3d112 __CFRunLoopDoSource1 + 134
55 CoreFoundation 0x35b3bf94 __CFRunLoopRun + 1380
56 CoreFoundation 0x35aaeeb8 CFRunLoopRunSpecific + 352
57 CoreFoundation 0x35aaed44 CFRunLoopRunInMode + 100
58 GraphicsServices 0x318872e6 GSEventRunModal + 70
59 UIKit 0x362b62f4 UIApplicationMain + 1116
Neither thread activities are involved nor ViewControllers are customized. Moreover, I am using ARC.
I would like to know either the exact cause of reason or the possibilities which would lead to a crash while autorotation is taking place.
Thanks in advance...
I think app sends a message to an deallocated object. Yes, sometimes it happens even if when you use ARC. To debug it you need to run your app with Instruments (Zombies) and try to reproduce the bug.
Enabling Zombies and debugging the App with Instruments (Zombies) has really helped to locate the error. But to fix the bug or avoid the same mistake in the future is really important.
In my code, I had an implementation something like this...
- (void)someMethod {
[self.navigationController pushViewController:[DestinationViewController new] animated:YES];
}
there we are not holding the DestinationViewController's strong reference directly. But the change...
#property (strong, nonatomic) DestinationViewController *dvc;
// ....
- (void)someMethod {
self.dvc = [DestinationViewController new];
[self.navigationController pushViewController:self.dvc animated:YES];
}
has helped to avoid the bug. I can't really explane why...??? but I hope changing the device orientation releses DestinationViewController but which can be avoided by holding the strong reference.

Crash when installing the app on ipad, works fine in simulator

I am gettting the below issue in my application (Pls help me):
*** Terminating app due to uncaught exception 'CALayerInvalidGeometry', reason: 'CALayer position contains NaN: [1.07157e-08 nan]'
*** Call stack at first throw:
(
0 CoreFoundation 0x3126a64f __exceptionPreprocess + 114
1 libobjc.A.dylib 0x32b12c5d objc_exception_throw + 24
2 CoreFoundation 0x3126a491 +[NSException raise:format:arguments:] + 68
3 CoreFoundation 0x3126a4cb +[NSException raise:format:] + 34
4 QuartzCore 0x32c6f61d _ZL18CALayerSetPositionP7CALayerRKN2CA4Vec2IdEEb + 140
5 QuartzCore 0x32c6f58b -[CALayer setPosition:] + 38
6 QuartzCore 0x32c6f4d7 -[CALayer setFrame:] + 390
7 UIKit 0x35a31455 -[UIView(Geometry) setFrame:] + 188
8 UIKit 0x35a51743 UIViewCommonInitWithFrame + 594
9 UIKit 0x35a514a1 -[UIView initWithFrame:] + 84
10 CaCaCard 0x0000683b -[CaCaCardsAppViewController shouldAutorotateToInterfaceOrientation:] + 510
11 UIKit 0x35a6eead -[UIViewController _isSupportedInterfaceOrientation:] + 48
12 UIKit 0x35a6ee6f -[UINavigationController _doesTopViewControllerSupportInterfaceOrientation:] + 46
13 UIKit 0x35a6ee37 -[UINavigationController shouldAutorotateToInterfaceOrientation:] + 14
14 UIKit 0x35a6edbf -[UINavigationController _isSupportedInterfaceOrientation:] + 54
15 UIKit 0x35a6fbbb -[UIViewController window:shouldAutorotateToInterfaceOrientation:] + 46
16 UIKit 0x35a6f857 -[UIWindow _shouldAutorotateToInterfaceOrientation:] + 194
17 UIKit 0x35a6f4a3 -[UIWindow setAutorotates:forceUpdateInterfaceOrientation:] + 366
18 UIKit 0x35a6f0ad -[UIWindow setDelegate:] + 168
19 UIKit 0x35a6efa9 -[UIViewController _tryBecomeRootViewControllerInWindow:] + 64
20 UIKit 0x35a6d611 -[UIViewController viewDidMoveToWindow:shouldAppearOrDisappear:] + 460
21 UIKit 0x35a6d3e5 -[UINavigationController viewDidMoveToWindow:shouldAppearOrDisappear:] + 36
22 UIKit 0x35a4c5a7 -[UIView(Internal) _didMoveFromWindow:toWindow:] + 506
23 UIKit 0x35a4c32f -[UIView(Hierarchy) _postMovedFromSuperview:] + 106
24 UIKit 0x35a31c1b -[UIView(Internal) _addSubview:positioned:relativeTo:] + 678
25 UIKit 0x35a3196b -[UIView(Hierarchy) addSubview:] + 22
26 CaCaCard 0x00004bcf -[CaCaCardsAppAppDelegate application:didFinishLaunchingWithOptions:] + 318
27 UIKit 0x35a61821 -[UIApplication _callInitializationDelegatesForURL:payload:suspended:] + 772
28 UIKit 0x35a5bb65 -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 272
29 UIKit 0x35a307d7 -[UIApplication handleEvent:withNewEvent:] + 1114
30 UIKit 0x35a30215 -[UIApplication sendEvent:] + 44
31 UIKit 0x35a2fc53 _UIApplicationHandleEvent + 5090
32 GraphicsServices 0x31d37e77 PurpleEventCallback + 666
33 CoreFoundation 0x31241a97 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 26
34 CoreFoundation 0x3124383f __CFRunLoopDoSource1 + 166
35 CoreFoundation 0x3124460d __CFRunLoopRun + 520
36 CoreFoundation 0x311d4ec3 CFRunLoopRunSpecific + 230
37 CoreFoundation 0x311d4dcb CFRunLoopRunInMode + 58
38 UIKit 0x35a5ad49 -[UIApplication _run] + 372
39 UIKit 0x35a58807 UIApplicationMain + 670
40 CaCaCard 0x000028e7 main + 70
41 CaCaCard 0x0000289c start + 40
)
terminate called after throwing an instance of 'NSException'
Program received signal: “SIGABRT”.
warning: Unable to read symbols for /Developer/Platforms/iPhoneOS.platform/DeviceSupport/4.3.5 (8L1)/Symbols/Developer/usr/lib/libXcod
eDebuggerSupport.dylib (file not found).
(gdb)
-(void) viewWillAppear:(BOOL)animated
//-----------------------------------
{
if ( self.interfaceOrientation == UIInterfaceOrientationPortrait ||
self.interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown )
{
[NSThread sleepForTimeInterval:0.5];
[UIView beginAnimations:#"View Flip" context:nil];
[UIView setAnimationDuration:1.25];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[[UIApplication sharedApplication] setStatusBarOrientation:
UIInterfaceOrientationLandscapeRight];
UIScreen *screen = [UIScreen mainScreen];
CGFloat screenWidth = screen.bounds.size.width;
CGFloat screenHeight = screen.bounds.size.height;
UIView *navView = [[self navigationController] view];
navView.bounds = CGRectMake(0, 0, screenHeight, screenWidth);
navView.transform = CGAffineTransformIdentity;
navView.transform = CGAffineTransformMakeRotation(degreesToRadian(90));
navView.center = CGPointMake(screenWidth/2.0, screenHeight/2.0);
[UIView commitAnimations];
}
fontSelected = NO;
}
The problem is an invalid frame size you are setting at some point. Probably a rect with a zero value somewhere.
From your code I would suspect you are getting some unexpected values back when you are asking for the screen size.
Also don't use those old animation functions. Use the block based animation. It's much better.

Resources