3

Basically what I want to do in my app is have a UISearchBar which, when I write in, will feedback location results and populate that into a UITableView that appears. I see one more question on this site:

Display Locations on UITableview

But that really didn't help me, no answer helped me at all, and they were quite vague.

So, my question is. You know how some apps maybe you have to type in a city or country, but the user might not be able to fully spell it, so based on your UISearchBar results, it presents a TableView with the suggested cities. So say I am about to write Singapore, I don't know how it is spelled. So I write:

'Sing'

And BAM, a UITableView below pops up with different options/cell titles, including a cell that suggests 'Singapore'. Then I click on that cell and then my search bar is autofilled with 'Singapore'. Here is a screenshot example of what I want to do with a current app called 'iChangi' on the Singapore app store:

Screenshot of what I am trying to do

So I understand I should implement the UISearchBar delegate where the text changed, but what I want to know is there an API or database I can query to feedback the suggested cities? And how would I go around doing this, can you provide me with a tutorial on it or simply state a few steps.

Community
  • 1
  • 1
MCKapur
  • 9,127
  • 9
  • 58
  • 101
  • 1
    I think the downvote is because it's not clear what you are asking. Why is displaying locations any different to displaying any other data? What problem do you actually have? Asking for "personal thoughts" is begging for a "not constructive" close vote. An answer consisting of tutorial links is not a good fit for SO ( link only answers may not be useful in a years time). – jrturton May 20 '12 at 06:22
  • OK ill rephrase my question... then come back to see if you can help me ;) – MCKapur May 20 '12 at 06:26
  • It's a much better question now! I don't know the answer, but I've given you an upvote :) – jrturton May 20 '12 at 06:49
  • oh ok thanks!!!!! Man, I really need an answer to this!!!!!! – MCKapur May 20 '12 at 07:22

3 Answers3

5

With the Help of Table view and search bar you can create presentation of City list. Now about API for city list there is many link availibale on Map for same. Please refer below

http://www.geonames.org/export/

https://developers.google.com/adwords/api/docs/appendix/cities_world

Download Table from above URL and place this with resource directory and use this for suggestion.

See more link for same

http://www.geodatasource.com/cities-free.html

http://weather.noaa.gov/data/nsd_cccc.txt

http://www.geonames.org/export/JSON-webservices.html#citiesJSON

Mangesh
  • 2,257
  • 4
  • 24
  • 51
  • but can you please provide a bit more detailed explanation on the API, I am quite a beginner at that.... thanks! – MCKapur May 21 '12 at 12:16
  • Please refer Left hand side of Google API, there is a list of items. Started API and all. Read this document, and create credential for the same. – Mangesh May 21 '12 at 12:26
  • Or simaply download City table xls and use this file for suggestion. If you have server side implementation in your app then ask server side developer for City list. It would be easy on server. – Mangesh May 21 '12 at 12:28
  • See my Updated ans, may it help you – Mangesh May 21 '12 at 12:44
  • thank you ill try it out! Also, I will give you the +50 only when the bounty ends... – MCKapur May 21 '12 at 12:55
  • https://developers.google.com/adwords/api/docs/appendix/cities_world.csv Link looks interesting, with a full list of the cities, how would I go around implementing that, sorry if I am asking too many questions, it is just that this is a pretty new topic to me – MCKapur May 21 '12 at 12:58
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/11522/discussion-between-mangesh-vyas-and-rohan-kapur) – Mangesh May 21 '12 at 13:00
2

Check this project http://iosboilerplate.com/#maps

torhector2
  • 443
  • 1
  • 5
  • 19
  • Hmmm... I have tried moving over that code to my computer but it seems to fail to build because it cant find the implementation for JSONDecoder which is in the JSONKit which I have clearly imported – MCKapur May 23 '12 at 13:22
  • it is referenced in the AFJSONRequestOperation class – MCKapur May 23 '12 at 13:25
  • Check if JSONKit it's added in Build Phases -> Compile Sources. – torhector2 May 23 '12 at 14:47
  • Note: this project uses a deprecated Google API. If you want to use this project you'll need to convert it to use the [Google Places API](https://developers.google.com/places/documentation/autocomplete) – Joel Sep 14 '13 at 07:07
2

I know it's quite late, but maybe it can help others, I've recently created autocomplete view, which can be attached to any UITextField, with single line of code. Colors, separators, margins can be configured. Ships with google locations completion source.

You can clone it from GitHub

illegal-immigrant
  • 8,089
  • 9
  • 51
  • 84