I am trying to make my application open the apple maps application and have the address be pulled up. I tried this :
- (IBAction)openInMaps:(id)sender {
NSS
Swift 2 version that is formatted nicely, safely handles optionals, and won't crash your app:
let baseUrl: String = "http://maps.apple.com/?q="
let encodedName = "address".stringByAddingPercentEncodingWithAllowedCharacters(.URLQueryAllowedCharacterSet()) ?? ""
let finalUrl = baseUrl + encodedName
if let url = NSURL(string: finalUrl) {
UIApplication.sharedApplication().openURL(url)
}