Search code examples
iphonedatabasedata-layers

Where do I place Data Layer in iPhone App


In .Net I usually create a separate class library and reference it in my project. This class library does all the select, insert and updates to the database. Or, I put classes or static methods in the App_Code folder.

In iPhone Dev, where do I put this data layer in order to have a separation in code and logic. This layer, files, would be accessed by all the views, controllers that need data and want to write to the database.


Solution

  • What you are talking about is the Model part of MVC. I typically have a Class for each major table in my database that has all the necessary methods for handling that table.

    So I have GeoNames.m/.h that interacts with my geonames table is sqlite and provides hydrate/dehydrate, query and misc helper methods.