I'm wanting to get an iPhones location data, primarily the city and state, returned in an array. Suggestions?
Asked
Active
Viewed 99 times
-2
-
What is your problem: 1) retrieving the location, 2) parsing city and state from the location or 3) adding the city and state into an array? – sch Mar 17 '12 at 19:37
-
Use Google Map API's and Parse the data and save the desired values in array. – Khalid Usman Mar 17 '12 at 22:13
1 Answers
0
I am not sure what exactly do you want, but I'll do my best.
- You will need to get location data using CLLocationManager and CoreLocation framework.
- You will have to reverse geocode the data you've got. You can use the Google reverse geocoding framework (MKReverseGeocoder) which is included in the SDK or you can use some other online service. The biggest caveat of the Google options is that you have to display a Goggle Map onscreen.
- Once you get the required data (city and state) simply create an array of strings, or whatever you want :)
There are many online tutorials for this and also many questions on StackOverflow.
This is probably a duplicate of the question below.
How to retrieve user's current city name?
EDIT:
However, if don't want to use Google Maps then you can use many online reverse geocoding services.
In my last app I have used GeoNames - http://www.geonames.org/ and https://github.com/InfiniteLoopDK/ILGeoNames.
It isn't very hard to do, just read the description on github well. I hope it helps, good luck :)

Community
- 1
- 1

Dominik Hadl
- 3,609
- 3
- 24
- 58