Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Mockup & CodeGen, iPhone & iPad
($9.99)

Make your own iPhone apps
and run them live!
(free)

Manu
($0.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum

View Single Post
Old 01-16-2010, 06:07 AM   #16 (permalink)
DAW
Registered Member
 
Join Date: Dec 2009
Posts: 3
Default

Quote:
Originally Posted by sbarham View Post
I'm going to go ahead and push my app with MKReverseGeocoder and complain to apple.
Don't! The Google one is infinitely better. So much quicker!

// Show network activity Indicator (no need really as its very quick)
[[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:YES];

// Use Google Service
// OK the code is verbose to illustrate step by step process

// Form the string to make the call, passing in lat long
NSString *urlString = [NSString stringWithFormat:@"http://maps.google.com/maps/geo?q=%lf,%lf&output=csv&sensor=false&key=swizzlec hops", coordinate.latitude,coordinate.longitude];

// Turn it into a URL
NSURL *urlFromURLString = [NSURL URLWithString:urlString];

// Use UTF8 encoding
NSStringEncoding encodingType = NSUTF8StringEncoding;

// reverseGeoString is what comes back with the goodies
NSString *reverseGeoString = [NSString stringWithContentsOfURL:urlFromURLString encoding:encodingType error:nil];

// If it fails it returns nil
if (reverseGeoString != nil)
{

// Break up the tokens returned in the string
// They are comma separated
// The first one is the success code (glass always half full)
// Put this into an array to tokenise
NSArray *listItems = [reverseGeoString
componentsSeparatedByString:@","];

// So the first object in the array is the success code
// 200 means everything is happy
if ([[listItems objectAtIndex:0] isEqualToString:@"200"])
{
// Get the address quality
// We should always have this, but you never know
if ([listItems count] >= 1)
{
NSString *addressQuality =[listItems objectAtIndex:1];
// You can store this somewhere 9 is best, 8 is still great
// You can read Googles doco for an explanation
// e.g. [NSNumber numberWithInteger:[addressQuality intValue]]
}
// Get the address string.
// I am just creating another array to extract the quoted address
NSArray *quotedPart = [reverseGeoString componentsSeparatedByString:@"\""];

// It should always be there as objectAtIndex 1
if ([quotedPart count] >= 2)
{
NSString *address = [quotedPart objectAtIndex:1];
}
}
}

// Hide network activity indicator
[[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:NO];


Sorry about the formatting, I am from a generation before posting code on forums :-)
DAW is offline   Reply With Quote
 

» Advertisements
» Online Users: 293
13 members and 280 guests
ADY, aikhan, astalavista, chemistry, chits12345, dcool, Joseph Nardone, leahov, mer10, NSeven, Paul10, Promo Dispenser, RoryHarvey
Most users ever online was 1,187, 10-11-2011 at 08:09 AM.
» Stats
Members: 158,877
Threads: 89,219
Posts: 380,705
Top Poster: BrianSlick (7,129)
Welcome to our newest member, peterkessler45
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 09:20 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.