Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SIG ABORT problem when lowEstimate is not returned #4

Closed
pirtil opened this issue Aug 30, 2014 · 1 comment
Closed

SIG ABORT problem when lowEstimate is not returned #4

pirtil opened this issue Aug 30, 2014 · 1 comment

Comments

@pirtil
Copy link

pirtil commented Aug 30, 2014

I got response where estimated prices were not available. It caused app to crash.
Log:

2014-08-30 15:22:08.236 UberKitDemo[5996:4007] Object being sent to price {
"currency_code" = USD;
"display_name" = UberSUV;
estimate = "$118-150";
"high_estimate" = 150;
"localized_display_name" = UberSUV;
"low_estimate" = 118;
"product_id" = "8920cb5e-51a4-4fa4-acdf-dd86c5e18ae0";
"surge_multiplier" = 1;
}
2014-08-30 15:22:08.237 UberKitDemo[5996:4007] Object being sent to price {
"currency_code" = "";
"display_name" = uberTAXI;
estimate = Metered;
"high_estimate" = "";
"localized_display_name" = uberTAXI;
"low_estimate" = "";
"product_id" = "3ab64887-4842-4c8e-9780-ccecd3a0391d";
"surge_multiplier" = 1;
}
2014-08-30 15:22:08.237 UberKitDemo[5996:4007] -[NSNull intValue]: unrecognized selector sent to instance 0x1940068
2014-08-30 15:22:08.245 UberKitDemo[5996:4007] *** Terminating

My fix:
UberPrice.m, line 40:
_lowEstimate = -1;
_highEstimate = -1;
NSString *lowE = [dictionary objectForKey:@"low_estimate"];
NSString *highE = [dictionary objectForKey:@"high_estimate"];
if ( ![lowE isKindOfClass:[NSNull class]] )
_lowEstimate = [lowE intValue];
if ( ![highE isKindOfClass:[NSNull class]] )
_highEstimate = [highE intValue];

UberKit.m, line 92:
for(int i=0; i<prices.count; i++)
{
NSLog(@"Object being sent to price %@", [prices objectAtIndex:i]);
UberPrice *price = [[UberPrice alloc] initWithDictionary:[prices objectAtIndex:i]];
if ( price.lowEstimate > -1) //added this
[availablePrices addObject:price];
}

@sachinkesiraju
Copy link
Owner

Hey there,
The crash appears to occur because UberKit assumes a value for every field even though sometimes the Uber API doesn't return a value for some fields, in this case, for a metered cab. Your solution to the issue seems apt. I just pushed an update that features your solution.
Thanks,
Sachin

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants