Skip navigation.
 
ml[Q] Any document that shows differences of Cocoa programming for Mac and for the iPhone/iPod touch?
FROM : JongAm Park
DATE : Mon Jul 14 22:15:48 2008

Hello, all.

Because the final SDK for the iPhone came out, I started to take a look
at it.
Although I knew that Window/View hierarchies are different on the Mac
and the iPhone, I found that there were some fundamental difference in
programming model.

For example, this code from
http://developer.apple.com/iphone/gettingstarted/docs/creatingiphoneapps.action,
it creates a view controller and add its view as a window's sub view.

Listing 2. Creating the content view

- (void) applicationDidFinishLaunching:(UIApplication *)application
{
    // Set up the view controller
    UIViewController *aViewController = [[UIViewController alloc]
initWithNibName:@"MoveMeView"
                                                                       
                                                bundle:[NSBundle
mainBundle]];
    self.viewController = aViewController;
    [aViewController release];

    // Add the view controller's view as a subview of the window
    UIView *controllersView = [viewController view];
    [window addSubView:controllersView];
    [window makeKeyAndVisible];
}


However, for the Mac, something like the view controller was not
necessary, right? and a content view is not added manually like the code
above. ( I don't mean that "Oh, there is no UIViewController and
UIView". I know that those are made for the iPhone. )
When a window and its view are made using the Interface Builder, they
were handled automatically for the Mac.
Isn't this true for the iPhone?

(Well, I just looked up "NSViewController" document and it says that it
was added to the Leopard.
Is there any document which explains why it is added and how the
programming model is changed due to the addition of it? )

Thank you.