Objective-C iOS app crashes during CFStringAppend for unknown reason - ios

In my iPhone app, for some users the app will always crash, whenever they open a certain window. The same window works fine for me and other people, but always causes a crash for some people. It is unclear at this moment what the difference is between people for whom it fails, and for whom it works fine.
The animation to open the specific view will run fine, but will then cause a crash immediately after the animation is finished.
They have sent me the crashlog, but it is hard to understand what is exactly going wrong. I am hoping you can help me understand. The cause for the failure as given by the crashlog is the following exception:
Last Exception Backtrace:
0 CoreFoundation 0x1836ffd38 __exceptionPreprocess + 124
1 libobjc.A.dylib 0x182c14528 objc_exception_throw + 55
2 CoreFoundation 0x18370d1f8 -[NSObject+ 1372664 (NSObject) doesNotRecognizeSelector:] + 139
3 UIKit 0x18cec7cc4 -[UIResponder doesNotRecognizeSelector:] + 295
4 CoreFoundation 0x1837056e4 ___forwarding___ + 1379
5 CoreFoundation 0x1835eb0dc _CF_forwarding_prep_0 + 91
6 CoreFoundation 0x1835d6be8 CFStringAppend + 519
7 CoreFoundation 0x1836bddf0 __CFStringAppendFormatCore + 9271
8 CoreFoundation 0x1836bf658 _CFStringCreateWithFormatAndArgumentsAux2 + 131
9 AccessibilityUtilities 0x192d6b388 _AXStringForArgs + 279
10 UIKit 0x1a242adf8 -[UIViewControllerAccessibility viewDidAppear:] + 267
11 UIKit 0x18cb2869c -[UIViewController _setViewAppearState:isAnimating:] + 851
12 UIKit 0x18cb28c08 -[UIViewController _endAppearanceTransition:] + 227
13 UIKit 0x18cbcee00 -[UINavigationController navigationTransitionView:didEndTransition:fromView:toView:] + 1327
14 UIKit 0x1a2440cd4 -[UINavigationControllerAccessibility navigationTransitionView:didEndTransition:fromView:toView:] + 111
15 UIKit 0x18cc96bbc __49-[UINavigationController _startCustomTransition:]_block_invoke + 251
16 UIKit 0x18cc229d8 -[_UIViewControllerTransitionContext completeTransition:] + 115
17 UIKit 0x18cd67d30 __53-[_UINavigationParallaxTransition animateTransition:]_block_invoke.124 + 751
18 UIKit 0x18cb47d7c -[UIViewAnimationBlockDelegate _didEndBlockAnimation:finished:context:] + 763
19 UIKit 0x18cb4770c -[UIViewAnimationState sendDelegateAnimationDidStop:finished:] + 311
20 UIKit 0x18cb47418 -[UIViewAnimationState animationDidStop:finished:] + 295
21 UIKit 0x1a2468970 -[UIViewAnimationStateAccessibility animationDidStop:finished:] + 131
22 QuartzCore 0x1876ebd6c CA::Layer::run_animation_callbacks+ 1232236 (void*) + 283
23 libdispatch.dylib 0x183085048 _dispatch_client_callout + 15
24 libdispatch.dylib 0x183091b74 _dispatch_main_queue_callback_4CF$VARIANT$mp + 1015
25 CoreFoundation 0x1836a7f20 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 11
26 CoreFoundation 0x1836a5afc __CFRunLoopRun + 2011
27 CoreFoundation 0x1835c62d8 CFRunLoopRunSpecific + 435
28 GraphicsServices 0x185457f84 GSEventRunModal + 99
29 UIKit 0x18cb73880 UIApplicationMain + 207
30 Flyskyhy 0x10490bd80 main + 32128 (main.m:17)
31 libdyld.dylib 0x1830ea56c start + 3
The crashlog seems to indicate that it goes wrong while doing a CFStringAppend, but it is not clear which string is the problem, or what is wrong with it, or even why a CFStringAppend is needed. All strings visible in the view have been filled in already before the animation starts, and they all are correct.
EDIT:
As requested, here is the code that starts the view. Everything is under a NavigationController, so the new view controller is pushed on the navigation stack to open it.
WaypointEditController *controller = [[WaypointEditController alloc] initWithNibName:#"WayPointEdit" bundle:nil];
controller.navigationItem.title = #"New Waypoint";
// initialisation of other, custom, fields of controller
[self.navigationController pushViewController:controller animated:YES];
The WaypointEditController class that is pushed is derived from UIViewController. The viewWillAppear is overridden, to do initialisation of the fields of the view. But - relevant here - viewDidAppear is not overridden.
In case relevant, here are the most important actions in the viewWillAppear method:
- (void) viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
[self.navigationController setNavigationBarHidden:NO animated:YES];
self.navigationItem.title = #"New Waypoint";
// other initialisation of internal fields
}

Like you, I have customers reporting this problem and I could see the stack traces that XCode downloaded from production but I could not reproduce it... until I tried enabling "voice over".
The other accessibility options that I tried worked OK.
The stack trace shows that iOS is sending a selector of "length" to an instance of UILabel. This seemed odd. To see what would happen, I added a "length" method to UILabel to return the length of the UILabel's text property. Then it just failed with an unknown selector of _encodingCantBeStoredInEightBitCFString. So clearly iOS thought that my UILabel was something that it wasn't.
This ended up being because "description" was used for the name of my UILabel property/IBOutlet.
To fix the problem I renamed the property from "description" to something different. I suspect that my synthesized "description" getter was overriding NSObject's description method (which returns an NSString which fits the selectors which were being sent to my UILabel).

Related

UIButton _setTitleFrozen crash

I have weird crash related to UIButton class. I have not found anything similar on SO yet. The log I get comes from Crashlytics so I also don't know which part of code is causing the issue. I put crash log below, may be some of you have already found out what is creating the problem.
EXC_BAD_ACCESS KERN_INVALID_ADDRESS at 0xd1712d18
0 libobjc.A.dylib objc_msgSend + 5 _setTitleFrozen:
1 UIKit 32-[UIButton _beginTitleAnimation]_block_invoke853 + 28
2 UIKit -[UIViewAnimationBlockDelegate_didEndBlockAnimation:finished:context:] + 308
3 UIKit -[UIViewAnimationState sendDelegateAnimationDidStop:finished:] + 184
4 UIKit -[UIViewAnimationState animationDidStop:finished:] + 70
5 QuartzCore CA::Layer::run_animation_callbacks(void*) + 234
6 libdispatch.dylib _dispatch_client_callout + 22
7 libdispatch.dylib _dispatch_main_queue_callback_4CF$VARIANT$mp + 712
8 CoreFoundation __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE_ + 8
9 CoreFoundation __CFRunLoopRun + 1512
10 CoreFoundation CFRunLoopRunSpecific + 476
11 CoreFoundation CFRunLoopRunInMode + 106
12 GraphicsServices GSEventRunModal + 136
13 UIKit UIApplicationMain + 1440
Changing the button type from System to Custom resolved this crash for me.
In my case this crash occurred because I was changing the button title right before removing it from the view hierarchy (by dismissing its parent view's VC) while the title change animation was still running.

-[UIViewController _keyboard]: unrecognized selector sent to instance 0x7b731ac0

I am writing an app with 3 viewControllers contained inside of a MainViewController. One of these is controlled through the storyboard and shows ads. The other two viewControllers are displaying information. Depending on the menu button pressed and the viewController to be presented the app determines which viewController to change.
So far everything is working well except when ANY textField is selected. This causes the error to display. The instance is the viewController containing the textField, and is also the UIViewController named in the error. Also, the instance is not nil. I've placed a breakpoint at: textFieldShouldBeginEditing:
and this method is called before the crash happens. The app is universal and doesn't crash on the iPhone version, which uses the same setup except it only has the ads and another viewController displayed. Let me know if you need to see more code or have any ideas. I can't find the selector _keyboard anywhere and have no idea what to do from here.
I've tried to create a new project with minimal code to show the error, but new projects all work fine, so the problem isn't having too many viewControllers visible at once. I also know my transitioning code works fine because it works in the new projects. The viewControllers I've written are also not the problem, because the exact same viewController is used in the iPhone part of the app as well as in a new iPad only test project and the problem doesn't show up on them at all.
[edit - removed code, I tested the code in a new project and it worked fine]
[edit2 - added code and explanation]
#implementation FSMainiPadViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.leftView = [[UIView alloc] init];
self.rightView = [[UIView alloc] init];
if (!self.testVC) {
self.testVC = [[FSTestViewController alloc] initWithNibName:nil bundle:nil];
}
self.inputViewController = self.testVC;
self.resultsVC = [[FSResultsTableViewController alloc] initWithNibName:nil bundle:nil];
self.dataViewController = self.resultsVC;
self.leftView.frame = CGRectMake(0, VIEWFRAMEOFFSET/2, self.view.frame.size.width/2 , self.view.frame.size.height - IPADBANNERHEIGHT - VIEWFRAMEOFFSET/2 - MENUHEIGHT);
self.rightView.frame = CGRectMake((self.view.frame.size.width)/2, VIEWFRAMEOFFSET/2, self.view.frame.size.width/2, self.view.frame.size.height - IPADBANNERHEIGHT - VIEWFRAMEOFFSET/2 - MENUHEIGHT);
[self addChildViewController:self.inputViewController];
[self addChildViewController:self.dataViewController];
[self.view addSubview:self.inputViewController.view];
[self.view addSubview:self.dataViewController.view];
[self.dataViewController didMoveToParentViewController:self];
[self.inputViewController didMoveToParentViewController:self];
}
Selecting the textField causes this same error. I have literally commented out everything else in my MainViewController and it still causes this issue, but if I create a new project, even including my more complicated code and xib's, I can't recreate the crash.
Let me know if you want more code.
Stacktrace
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[FSSettingsViewController _keyboard]: unrecognized selector sent to instance 0x7da1dbf0'
*** First throw call stack:
(
0 CoreFoundation 0x0326d946 __exceptionPreprocess + 182
1 libobjc.A.dylib 0x02ef6a97 objc_exception_throw + 44
2 CoreFoundation 0x032755c5 -[NSObject(NSObject) doesNotRecognizeSelector:] + 277
3 CoreFoundation 0x031be3e7 ___forwarding___ + 1047
4 CoreFoundation 0x031bdfae _CF_forwarding_prep_0 + 14
5 UIKit 0x01e46d91 -[UIInputViewSet keyboard] + 52
6 UIKit 0x01b0807c -[UIKeyboardImpl setOrientation] + 94
7 UIKit 0x01b082c8 -[UIKeyboardImpl setFrame:] + 197
8 UIKit 0x01939084 UIViewCommonInitWithFrame + 1072
9 UIKit 0x01938bea -[UIView initWithFrame:] + 124
10 UIKit 0x01b02b62 -[UIKeyboardImpl initWithFrame:] + 107
11 UIKit 0x01b01c58 +[UIKeyboardImpl sharedInstance] + 158
12 UIKit 0x01e3bf4f -[UIPeripheralHost(UIKitInternal) _reloadInputViewsForResponder:] + 962
13 UIKit 0x01a845a5 -[UIResponder(UIResponderInputViewAdditions) reloadInputViews] + 316
14 UIKit 0x01a838ec -[UIResponder becomeFirstResponder] + 562
15 UIKit 0x0194a1c0 -[UIView(Hierarchy) becomeFirstResponder] + 114
16 UIKit 0x02115477 -[UITextField becomeFirstResponder] + 51
17 UIKit 0x01d183ef -[UITextInteractionAssistant(UITextInteractionAssistant_Internal) setFirstResponderIfNecessary] + 200
18 UIKit 0x01d1aa16 -[UITextInteractionAssistant(UITextInteractionAssistant_Internal) oneFingerTap:] + 2762
19 UIKit 0x01d0e287 _UIGestureRecognizerSendActions + 327
20 UIKit 0x01d0cb04 -[UIGestureRecognizer _updateGestureWithEvent:buttonEvent:] + 561
21 UIKit 0x01d0eb4d -[UIGestureRecognizer _delayedUpdateGesture] + 60
22 UIKit 0x01d124ca ___UIGestureRecognizerUpdate_block_invoke661 + 57
23 UIKit 0x01d1238d _UIGestureRecognizerRemoveObjectsFromArrayAndApplyBlocks + 317
24 UIKit 0x01d06296 _UIGestureRecognizerUpdate + 3720
25 UIKit 0x0191f26b -[UIWindow _sendGesturesForEvent:] + 1356
26 UIKit 0x019200cf -[UIWindow sendEvent:] + 769
27 UIKit 0x018e5549 -[UIApplication sendEvent:] + 242
28 UIKit 0x018f537e _UIApplicationHandleEventFromQueueEvent + 20690
29 UIKit 0x018c9b19 _UIApplicationHandleEventQueue + 2206
30 CoreFoundation 0x031911df __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15
31 CoreFoundation 0x03186ced __CFRunLoopDoSources0 + 253
32 CoreFoundation 0x03186248 __CFRunLoopRun + 952
33 CoreFoundation 0x03185bcb CFRunLoopRunSpecific + 443
34 CoreFoundation 0x031859fb CFRunLoopRunInMode + 123
35 GraphicsServices 0x0519f24f GSEventRunModal + 192
36 GraphicsServices 0x0519f08c GSEventRun + 104
37 UIKit 0x018cd8b6 UIApplicationMain + 1526
38 FoodStorage 0x000a795d main + 141
39 libdyld.dylib 0x04e14ac9 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
This is the first time the Google machine has let me down. In all the problems I've had making this app, this is the only problem I can't seem to find anyone else having.
I'm going to assume this code works flawlessly when running on an iOS7 device and probably when compiled against the iOS7 SDK on an iOS8 device.
You appear to have had the misfortune of naming one of your properties the same thing as an Apple added property:
#interface UIResponder (UIResponderInputViewAdditions)
// Called and presented when object becomes first responder. Goes up the responder chain.
#property (nonatomic, readonly, retain) UIInputViewController *inputViewController NS_AVAILABLE_IOS(8_0);
#end
When the user taps on your text field, UIKit will grab your view controller thinking it's a UIInputViewController and send the private message _keyboard. Your view controller doesn't implement this method and it crashes the app.
The only thing you need to do here is rename your property from inputViewController to something else like myInputViewController.
The problem is in your iPad storyboard. Check all the view controllers' connections. You might have a connection in the storyboard that doesn't get use, delete them. It has got to be there if it works on iPhone and not the iPad. Place breakpoints everywhere to see the last position before crash.

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];
}

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.

Low memory warning causes a crash on iOS5 - unloadViewForced

I have been able to replicate a low-memory crash on iOS devices that are running iOS5. Every time the stack trace points to the same place, so I know exactly where the problem is. Unfortunately I don't know how to fix it. As you can see below, the crash occurs when CatViewController receives a memory warning. At that point its view gets forcibly unloaded, then the crash happens:
0 libobjc.A.dylib 0x37174f7e objc_msgSend + 22
1 UIKit 0x317eab66 -[UIViewController unloadViewForced:] + 130
2 UIKit 0x31932492 -[UIViewController purgeMemoryForReason:] + 58
3 MyApp 0x001353c0 -[CatViewController didReceiveMemoryWarning] (CatViewController.m:89)
4 Foundation 0x339e34f8 __57-[NSNotificationCenter addObserver:selector:name:object:]_block_invoke_0 + 12
5 CoreFoundation 0x35178540 ___CFXNotificationPost_block_invoke_0 + 64
6 CoreFoundation 0x35104090 _CFXNotificationPost + 1400
7 Foundation 0x339573e4 -[NSNotificationCenter postNotificationName:object:userInfo:] + 60
8 Foundation 0x33958c14 -[NSNotificationCenter postNotificationName:object:] + 24
9 UIKit 0x318fd26a -[UIApplication _performMemoryWarning] + 74
10 UIKit 0x318fd364 -[UIApplication _receivedMemoryNotification] + 168
11 libdispatch.dylib 0x37ae6252 _dispatch_source_invoke + 510
12 libdispatch.dylib 0x37ae3b1e _dispatch_queue_invoke$VARIANT$up + 42
13 libdispatch.dylib 0x37ae3e64 _dispatch_main_queue_callback_4CF$VARIANT$up + 152
14 CoreFoundation 0x3517f2a6 __CFRunLoopRun + 1262
15 CoreFoundation 0x3510249e CFRunLoopRunSpecific + 294
16 CoreFoundation 0x35102366 CFRunLoopRunInMode + 98
17 GraphicsServices 0x3476d432 GSEventRunModal + 130
18 UIKit 0x31779e76 UIApplicationMain + 1074
19 MyApp 0x00087142 main (main.m:16)
20 MyApp 0x000870c8 start + 32
So I believe this has something to do with the way the view is getting unloaded on iOS5. This view controller is not removing itself from any notifications, so this solution doesn't work. Line 89 of CatViewController is just this:
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning]; //this is line 89
}
And viewDidUnload just looks like this:
- (void)viewDidUnload {
[self setBackgroundView:nil];
[self setContentView:nil];
[self setSomeScrollView:nil];
[super viewDidUnload];
}
Any ideas on how I can handle this gracefully without crashing?
EDIT: Here's more info on another crash report:
0 CoreFoundation 0x351ac88f __exceptionPreprocess + 163
1 libobjc.A.dylib 0x3717a259 objc_exception_throw + 33
2 CoreFoundation 0x351afa9b -[NSObject doesNotRecognizeSelector:] + 175
3 CoreFoundation 0x351ae915 ___forwarding___ + 301
4 CoreFoundation 0x35109650 _CF_forwarding_prep_0 + 48
5 UIKit 0x317eabdf -[UIViewController unloadViewForced:] + 251
6 UIKit 0x31932499 -[UIViewController purgeMemoryForReason:] + 65
7 MyApp 0x000d541b -[CatViewController didReceiveMemoryWarning] (CatViewController.m:96)
Your app is not crashing because it is out of memory. In your crash report, you can see that the exception thrown was actually [NSObject doesNotRecognizeSelector:].
Firstly, you should move those set to nil statements to didReceiveMemoryWarning; this is the preferred method since viewDidUnload is no longer supported in iOS 6.
Secondly, to find your crash, step through those statements where you set your properties to nil and make sure none of those cause the crash. Note that you will only have methods with those signatures (self set<propertyName>:]) if those variables are declared as properties, not as mere instance variables.

Resources