I'm trying to use NSURL to send the user to maps with a address from my db. And I want to do this in an action within a UIButton, like I do for tel, mail and web. Like this;
- (IBAction)restActionWeb:(UIButton *)sender {
NSString *urlString = [NSString stringWithFormat:@"http://%@",[restDetails objectForKey:@"Web"] ];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:urlString]];
}
Is it possible to to this for a streetaddress like "123 My Road, MyTown, CA 95472, USA"?
Tried this in some variations without any luck;
- (IBAction)restActionFind:(UIButton *)sender {
// Merge street + zip
NSMutableString *tempAdress = [NSMutableString string];
[tempAdress appendString:@"address://"];
[tempAdress appendFormat:@"%@",[restDetails objectForKey:@"Street"]];
[tempAdress appendFormat:@", %@",[restDetails objectForKey:@"Zip"]];
[tempAdress appendFormat:@", %@",[restDetails objectForKey:@"City"]];
[tempAdress appendFormat:@", USA"]; // Have this limitation in future?
self.restFindLabel.text = tempAdress;
// CHECK don't work, whats the url schema for address?
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:tempAdress]];
}
Would like it to work just like when you have en address detected in some textfield that you clic on and then go into maps with that address and show it.
I think it would be an "overkill" to use plan B: Use CoreLocation + sending address that way. And it also draws on the battery. I mean, I alread have the address in my dB and just want Maps to show it.
ANY suggestions or tips on this? THANKS! :-)