Reputation: 2598
I have the following code:
queryParams = @{@"geo_location" : [GlobalData sharedGlobalData].latLong, @"sale_ids": selectedSaleId};
It sometimes crashes on the live app, but we cannot reproduce the crash. I've been trying to analyze the report and understand what might be the cause of the crash, but I haven't been successful.
I would like some help understanding under what circumstances the following crash would occur:
1 __exceptionPreprocess + 1245624
2 libobjc.A.dylib objc_exception_throw + 34136
3 CoreFoundation -[__NSPlaceholderDictionary initWithObjects:forKeys:count:] + 81576
4 CoreFoundation +[NSDictionary dictionaryWithObjects:forKeys:count:] + 81176
5 MyApp -[SaleViewController loadStores] (SaleViewController.m:378)
6 MyApp -[SaleViewController viewDidLoad](SaleViewController.m:158)
7 UIKit -[UIViewController loadViewIfRequired] + 63776
8 UIKit -[UIViewController __viewWillAppear:] + 160944
9 UIKit -[UINavigationController _startCustomTransition:] + 1766832
10 UIKit -[UINavigationController _startDeferredTransitionIfNeeded:] + 818800
11 UIKit -[UINavigationController __viewWillLayoutSubviews] + 817880
Upvotes: 2
Views: 6827
Reputation: 62676
That's what the crash looks like when one of the values placed in a collection is nil. You can defend against this crash with a conditional:
if ([GlobalData sharedGlobalData].latLong && selectedSaleId) {
queryParams = @{@"geo_location" : [GlobalData sharedGlobalData].latLong, @"sale_ids": selectedSaleId};
}
Either that, or the debugging task at hand is to find out why either value was nil.
Upvotes: 1