Implementation of MVC with SQLite and NSURLConnection, use cases?

Posted by user324723 on Stack Overflow See other posts from Stack Overflow or by user324723
Published on 2010-04-24T09:01:59Z Indexed on 2010/04/24 9:13 UTC
Read the original article Hit count: 263

I'm interested in knowing how others have implemented/designed database & web services in their iphone app and how they simplified it for the entire application. My application is dependent on these services and I can't figure out a efficient way to use them together due to the (semi)complexity of my requirements. My past attempts on combining them haven't been completely successful or at least optimal in my mind.

I'm building a database driven iphone app that uses a relational database in sqlite and consumes web services based on missing content or user interaction. Like this hasn't been done before...right? Since I am using a relational database - any web services consumed requires normalization, parsing the result and persisting it to the database before it can be displayed in a table view controller. The applications UI consists of nested(nav controller) table views where a user can select a cell and be taken to the next table view where it attempts to populate the table views data source from the database. If nothing exists in the database then it will send a request via web services to download its content, thus download -> parse -> persist -> query -> display. Since the user has the ability to request a refresh of this data it still requires the same process.

Quickly describing what I've implemented and tried to run with -

1st attempt - Used a singleton web service class that handled sending web service requests, parsing the result and returning it to the table view controller via delegate protocols. Once the controller received that data it would then be responsible for persisting it to the database and re-returning the result. I didn't like the idea of only preventing the case where the app delegate selector doesn't exists(released) causing the app to crash.

2nd attempt - Used NSNotificationCenter for easy access to both database and web services but later realized it was more complex due to adding and removing observers per view(which isn't advised anyways).

© Stack Overflow or respective owner

Related posts about iphone

Related posts about nsnotification