This is not the way to achieve the directions,
I have made a sample for you which covers all the iOS versions, New Google Maps and the iOS 6 tom tom maps as well.
Here it is:
if([[[UIDevice currentDevice] systemVersion] compare:@"6.0" options:NSNumericSearch] == NSOrderedDescending){
//6.0 or above
NSString *Destinationlatlong =[NSString stringWithFormat:@"%@,%@",your.latitude,your.longitude];
NSString* addr = [NSString stringWithFormat:@"comgooglemaps://?saddr=%f,%f&daddr=%@",[AppDelegate zDelegate].location.coordinate.latitude,[AppDelegate zDelegate].location.coordinate.longitude, Destinationlatlong];
addr=[addr stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSURL* url = [[[NSURL alloc] initWithString:addr]autorelease];
// NSLog(@"url %@",url);
if ([[UIApplication sharedApplication]canOpenURL:url]) {
[[UIApplication sharedApplication] openURL:url];
}else{
CLLocationCoordinate2D coords =
CLLocationCoordinate2DMake([your.latitude doubleValue],[your.longitude doubleValue]);
MKPlacemark *placeMark = [[MKPlacemark alloc]
initWithCoordinate:coords addressDictionary:nil];
MKMapItem *destination = [[MKMapItem alloc]initWithPlacemark:placeMark];
[destination openInMapsWithLaunchOptions:nil];
}
}else{
NSString *Destinationlatlong =[NSString stringWithFormat:@"%@,%@",your.latitude,your.longitude];
NSString* addr = [NSString stringWithFormat:@"http://maps.google.com/maps?saddr=Current+Location&daddr=%@",Destinationlatlong];
addr=[addr stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSURL* url = [[[NSURL alloc] initWithString:addr]autorelease];
// NSLog(@"url %@",url);
if ([[UIApplication sharedApplication]canOpenURL:url]) {
[[UIApplication sharedApplication] openURL:url];
}else{
UIAlertView *alert=[[[UIAlertView alloc] initWithTitle:@"Warning!" message:@"Device does not support this functionality" delegate:nil cancelButtonTitle:@"Okay" otherButtonTitles: nil]autorelease] ;
[alert show];
}
}