Pretty address from coordinates in iOS using RubyMotion

by Luke, Founder

For a recent project, I needed to generate a nice address from lat/long coordinates. I've done this many times on web-based applications. It turns out it's even easier in iOS.

  cllocation = CLLocation.alloc.initWithLatitude(52.107631, longitude:0.040305)
  onReverseGeocode = Proc.new do |placemarks, error|
    unless error
      placemark = placemarks.lastObject
      address.text = ABCreateStringWithAddressDictionary(placemark.addressDictionary, false) 
    end
  end
  CLGeocoder.new.reverseGeocodeLocation(cllocation, completionHandler: onReverseGeocode)

You can also create your own string by using the placemark properties rather than the standard format ABCreateStringWithAddressDictionary.

More articles

Why engineering process is becoming a consultancy’s biggest advantage

As AI makes code faster to produce, the real differentiator for software consultancies is shifting to the engineering process around it.

Read more

Why mobile apps need ongoing support

Getting a mobile app into the App Store and Google Play is not the end of the story. Ongoing support keeps it compatible, reliable and store-ready as platforms change.

Read more
The Azuki team smiling and gathered together, ready to build and collaborate with clients.

Ready when you are

Let’s build something together

Whether you’re starting fresh or looking to improve things, we’re ready to talk.