views:

85

answers:

3

I am developing an app, which is huge project. I need to create an architecture for the app, so that I can reuse the code for another client.(app will be template I will change UI only)

Thinking to apply singleton pattern, but there are some very good design pattern available like MVC, Factory .... Can any one help to find out which is the best design patten I should implement in iPhone app. Or is there any code/tutorial available which explain with examples.

Thanks SD

+2  A: 

That's such a vague question that the only possible answer is "a good one."

You already have a choice of templates when you start a new iPhone app in Xcode. Those suggest architectures...

David Dunham
+3  A: 

The iPhone is completely geared toward MVC, so that one's a no-brainer. Don't try to use another pattern to organize your app - it'll just become a hacked up mess. As far as other patterns go, Singleton is always a good one. If you make singleton objects that manage common behaviors (networking, for example), you can reuse them in other projects pretty easily.

Custom views are also easy to re-use. If you create a custom UIView subclass for part of your UI and define Objective-C protocols for it's data source and delegate interactions (the points where it is tied into your controller and model), you should be able to take them with you to future projects.

Also consider using Core Data to store the "Model" part of your MVC app. Core Data is an ORM that is built into the iPhone platform. It allows you to store everything in an SQLLite database while working with Objective-C objects in your code. It's really handy if you're creating lots of apps with the same data or with the same UI but different data. (aka all those "fans of XYZ" apps!)

Ben Gotow
A: 

Also, if you want a good overview of the design patterns underlying Cocoa, I would suggest picking up the book Cocoa Design Patterns by Erik Buck and Donald Yacktman.

Brad Larson