Skip to content

Commit

Permalink
Fixed issue with app hanging when loading if Flickr key was invalid
Browse files Browse the repository at this point in the history
  • Loading branch information
xirianlight committed Apr 7, 2013
1 parent e45d5f6 commit f802993
Showing 1 changed file with 32 additions and 22 deletions.
54 changes: 32 additions & 22 deletions MappingMashupApp/APIManager.m
Expand Up @@ -27,27 +27,30 @@ - (APIManager*)initWithYelpSearch:(NSString*)search andLocation:(CLLocationCoord

float radius = 0.802336;

// Randomize keys
// Randomize keys - note that this has been commented out due to the increase of hits allowed David's key.
NSString *keyToUse = @"";

switch (arc4random()%4) {
case 0:
keyToUse = @"z8HZy2Hb2axZox05xfTW9w"; //Ross
break;
case 1:
keyToUse = @"xltTZDS7mgHV7wtu8MkZSg"; //Em
break;
case 2:
keyToUse = @"0mtAebqxwAxzHVOPI_OIyQ"; //Paul
break;
case 3:
keyToUse = @"ylWkpXJFz6-ZI3PvDG519A"; //David
break;
default:
keyToUse = @"z8HZy2Hb2axZox05xfTW9w";
NSLog(@"Did not return a proper Yelp key, returned default on random test");
break;
}
// switch (arc4random()%4) {
// case 0:
// keyToUse = @"z8HZy2Hb2axZox05xfTW9w"; //Ross
// break;
// case 1:
// keyToUse = @"xltTZDS7mgHV7wtu8MkZSg"; //Em
// break;
// case 2:
// keyToUse = @"0mtAebqxwAxzHVOPI_OIyQ"; //Paul
// break;
// case 3:
// keyToUse = @"ylWkpXJFz6-ZI3PvDG519A"; //David
// break;
// default:
// keyToUse = @"z8HZy2Hb2axZox05xfTW9w";
// NSLog(@"Did not return a proper Yelp key, returned default on random test");
// break;
// }

keyToUse = @"ylWkpXJFz6-ZI3PvDG519A"; //David


yelpAPICall = [NSString stringWithFormat:@"http://api.yelp.com/business_review_search?term=%@&lat=%f&long=%f&radius=%f&limit=%d&ywsid=%@", search, latitude, longitude, radius, maxItems, keyToUse];
NSLog(@"%@", yelpAPICall);
Expand All @@ -74,14 +77,18 @@ - (void)searchYelpThenFlickrForDelegates
{

NSString *search = @"color,+colorful,+shadow,+macro,+graffiti,+architecture,+street";
// NSString *search = @"color";

NSString* latitude = [[yelpBusinessesArray objectAtIndex:i] valueForKey:@"latitude"];
NSString *longitude = [[yelpBusinessesArray objectAtIndex:i] valueForKey:@"longitude"] ;

NSString *flickrKeyToUse = @"";

switch (arc4random()%4) {
case 0:
flickrKeyToUse = @"90087da25a0e607ed65734c6bbd4bc01dec7b05e"; //Em
//flickrKeyToUse = @"90087da25a0e607ed65734c6bbd4bc01dec7b05e"; //Em DISABLED
flickrKeyToUse = @"4dcd4b336fc303a2d36023d3c4c1b214"; //Ross

break;
case 1:
flickrKeyToUse = @"4dcd4b336fc303a2d36023d3c4c1b214"; //Ross
Expand All @@ -93,12 +100,15 @@ - (void)searchYelpThenFlickrForDelegates
flickrKeyToUse = @"b4a287d18b3f7398ffb4ab9f1b961e22"; //David
break;
default:
flickrKeyToUse = @"4dcd4b336fc303a2d36023d3c4c1b214";
flickrKeyToUse = @"b4a287d18b3f7398ffb4ab9f1b961e22"; //David
NSLog(@"Did not return a proper Yelp key, returned default on random test");
break;
}
flickrKeyToUse = @"b4a287d18b3f7398ffb4ab9f1b961e22";

flickrAPICall = [NSString stringWithFormat:@"http://api.flickr.com/services/rest/?method=flickr.photos.search&api_key=%@&tags=%@&format=json&nojsoncallback=1&lat=%@&lon=%@&radius=2&per_page=2&sort=interestingness-desc&content_type=1&extras=url_sq%%2C+geo%%2C+o_dims", flickrKeyToUse, search, latitude, longitude];

flickrAPICall = [NSString stringWithFormat:@"http://api.flickr.com/services/rest/?method=flickr.photos.search&api_key=%@&tags=%@&format=json&nojsoncallback=1&lat=%@&lon=%@&radius=0.1&per_page=2&sort=interestingness-desc&content_type=1&extras=url_sq%%2C+geo%%2C+o_dims", flickrKeyToUse, search, latitude, longitude];
// flickrAPICall = [NSString stringWithFormat:@"http://api.flickr.com/services/rest/?method=flickr.photos.search&api_key=%@&tags=%@&sort=interestingness-desc&content_type=1&lat=%@&lon=%@&radius=0.1&extras=geo%%2C+url_sq%%2C+o_dims&per_page=2&format=rest", flickrKeyToUse, search, latitude, longitude];
NSLog(@"%@", flickrAPICall);

[self searchFlickrWithLatitude:latitude andLongitude:longitude];
Expand Down

0 comments on commit f802993

Please sign in to comment.