Common Mac/iPhone development

Nibbie
Posts: 1
Joined: 2009.07
Post: #1
Hi all,

I'm new to Mac and iPhone development, and all I've done so far is absorb a couple books and a few blogs.

Well I have not found clear hints towards designing your app for both Mac and iPhone. Or, say, to minimize the amount of code which is to be redone for the second platform.

From my (limited) understanding, I gather that, given Model-View-Controller as the basic design pattern:
- Model objects: can of course be absolutely identical
- View objects: are of course different
- Controller objects: not clear how different they are, or better: can you structure your code to clearly separate out the "different objects"; use delegates ? use "categories" for slightly different methods ?

As a corollary, I sense that using Interface Builder and the lovely default controllers will ease your development for ONE of the platforms, but force you to redo all controller code for the second platform. So more hand-written code might be a better option ?

If any of you has already walked that path, I am interested by any hints.

Thanks in advance

PS: I will start with a simple book collection app, so nothing too fancy.
Quote this message in a reply
Member
Posts: 312
Joined: 2006.10
Post: #2
Cocoa and CocoaTouch is very similar. For the most part, you will be able to (and will want to) keep all your model code the same, since it shouldn't know anything about the GUI (view and controller). There will be a lot of parallels between your Mac controller and view, the design and interface should pretty much all be the same, but the API (names) will obviously be slightly different between the two platforms (ie, NSButton vs. UIButton). You will have to make those changes and will have to recreate your interface builder files (XIB/NIB).

One last thing, most Mac OS X applications usually have a more advance GUI (ie, multiple documents), so obviously there will be a direct correlation between the complexity of your Mac OS X app's GUI (controller and view) and the complexity of the port.
Quote this message in a reply
Moderator
Posts: 1,562
Joined: 2003.10
Post: #3
If you follow MVC strictly, you should definitely be able to have identical models and controllers across all platforms, and only have to reimplement views. Views can potentially have their own view controllers and view models, though, which would be view-specific and therefore platform-specific.
Quote this message in a reply
Post Reply