Store finder function for iPhone app?

Discussion in 'iOS Programming' started by dazcox5181, Apr 19, 2010.

  1. dazcox5181 macrumors 6502

    Jun 12, 2005
    Essex, UK

    I'm pretty new to iPhone development, but have dabbled in various languages in the past.

    I'm trying at present to find an easy way to add a few features to an app for my employer.

    We have a network of 300ish stores across UK, and would like to implement a store finder.

    I have the view setup with a map view which works, and have added buttons to either find your current location and a search bar to type in the city/town/region and it will add an annotation there.

    What I need to do is add in the 300ish store locations. Ideally I'd like to add an accessory view to the callout to include store details such as phone number etc.

    This is where I got stuck.

    I've got the addresses in a csv file which i've run through the Geocoder at so I now have the coordinates in the csv, also in this file are the phone numbers etc.

    How can I get this data available to my app? (easiest method please!)

    I thought I might be able to read in the file, but as it's an iphone app don't know if thats possible.

    If i can just get the annotations added I can worry about filtering them later for just the closest ones!

    Can anyone help please had a useless afternoon of googling so far on this.
  2. flyingturtle macrumors regular

    Apr 7, 2010
    As far as reading persistent data on the iPhone, you have several options.

    But I'd probably look at the database-related options since it's sounds like your reading from a database, your CSV file.

    1) If you have previous database experience, with some SQL knowledge, you can use SQLite to store your data as as SQLite database file and use iPhone SQLite API to read the necessary records. SQLite database is built in the iPhone. Just convert/import your CSV file to SQLite database file. Lots of SQLite and iPhone tutorials out there to help you with this.

    2) Alternatively you can use Core Data, which may be easier if you aren't familiar with SQL, and seems to be the preferred method for many. You may choose to go this route as I believe it'll involve less code writing.
  3. dejo Moderator


    Staff Member

    Sep 2, 2004
    The Centennial State
    Yes, iPhone apps can read files. Probably easiest using of the the various initWithContentsOfFile: instance methods. But you might be better off hosting this file on a remote server that the app retrieves, using something like NSURLConnection. That way you can update / add-to the file without having to update the app.
  4. dazcox5181 thread starter macrumors 6502

    Jun 12, 2005
    Essex, UK
    Thanks, thats actually what I ended up doing.

    What I want to eventually do will be to cache the file locally, and only update if it changes (rare)

    I even got the annotations working with callouts.

    The detail view is still an issue, as my app has a tab bar not to sure how to now add the a nav bar too, but thats todays challange and it's working at present with an action sheet.

Share This Page