Ipod application structure

Discussion in 'iOS Development' started by acca2o, Nov 7, 2009.

  1. acca2o

    acca2o New Member

    Joined:
    Sep 26, 2009
    Messages:
    51
    Likes Received:
    0
    Device:
    2G iPod touch
    Hoping not to be boring (sorry for my english)
    I'm studing and googling to understand the basic structure of any iphone/Ipod application, and to build a general template for them.
    I'm developing by cygwin, programmaticaly.
    But my question doesn't depend on the developing way or tool.

    I read about a model-view-controller concept.
    I understand that there is a main program that create a UIApplication subclass where I build my application.
    In the application object I define the root-user-interface (custom ViewControllers, NavigationControllers, TabBarControllers) and inside the root-viewcontrollers the child-views.
    Each root-viewcontroller manage its own views and each view manage the needed data object.
    But what a bout the data objects?
    Where I build my data objects (the model?)?
    are them properties of the application object?
    or I build them inside the root-viewcontrollers?
    or inside the child-views?
    or where?
    I think that to share the data objects I have to build them in the toplever of the hierarchy, in the application object.
    Is it right?

    Can you please give me some certainty about the general structure?
    Some link, some tutorial or just your experience.

    Thanks
    P
  2. lauNchD

    lauNchD Well-Known Member

    Joined:
    Jan 27, 2008
    Messages:
    1,844
    Likes Received:
    261
    Device:
    iPhone 5 (Black)
    You can create you own custom classes for everything. Here's an example of a cheap (as in cheaply made) pseudo contacts app:

    Model - should be the place for the actual data/information, which handles all properties, storage, etc.
    MyPersonGroup (NSMutableArray?)
    MyPerson (NSMutableDictionary?)
    name => @"John Doe"
    birthdate => [NSDate dateWithTimeIntervalSinceReferenceDate: -600000000] // some time in the 80s if I'm not mistaken
    whatever

    View - the highest level of user interaction. Should do all the drawing and (partly) event handling
    MyPotentialCustomViewForWhateverCustomDrawingINeedToDo
    UIView
    UITableView
    ...​

    Controller - the bridge between Model and View. The controller is responsible for delivering the view the correct information and reflecting changes from the view in the model (and vice-versa)
    UIViewController
    MyPersonViewController
    MyPersonGroupViewController​

    Check out Apple's Core Data Books example; it should be relatively easy to understand.

    Hope I clarified the difference between M/V/C for you a little!

Share This Page