Contact Us

Use the form on the right to contact us.

You can edit the text in this area, and change where the contact form on the right submits to, by entering edit mode using the modes on the bottom right. 


Oak Ridge, TN, 37830
United States

Swift-Snips

Address to Coordinates

Wade Cantley


Below you pass in the address string  to the method. Because this MUST run asynchronously, it needs to be stored someplace that can be accessed later.
In this case we are sending it to a method under a Utilities class that then saves it off.
 

import CoreLocation
public class thisClass: UIViewController {

    // Gets the location based on the passed address data and puts it into the database.
    public func findLocationFromAddress(address:String)->Bool {
       
        var returnedVal = true

        var geocoder = CLGeocoder()
        geocoder.geocodeAddressString(address, {(placemarks: [AnyObject]!, error: NSError!) -> Void in
            if let placemark = placemarks?[0] as? CLPlacemark {
               
                // put the coordinates into a method that will save it.
                let utilities = Utilities()
                let getLat = "\(placemark.location.coordinate.latitude)"
                let getLon = "\(placemark.location.coordinate.longitude)"
                utilities.updateLocation(getLat, lon: getLon)
            }
        })

        return returnedVal
       
    }

}