Model object

A model object is a type of object that contains the data of an application, provides access to that data, and implements logic to manipulate the data. Model objects play one of the three roles defined by the Model-View-Controller design pattern. (The other two roles are played by view and controller objects.) Any data that is part of the persistent state of the application (whether that persistent state is stored in files or databases) should reside in the model objects after the data is loaded into the application.

Because model objects represent knowledge and expertise related to a specific problem domain, they can be reused when that problem domain is in effect. Ideally, a model object should have no explicit connection to the view objects that present its data and allow users to edit that data—in other words, it should not be concerned with user-interface and presentation issues.

Model object

A Well-Designed Model Class

A model class—that is, a class that produces model objects—is typically a subclass of NSObject or, if you are taking advantage of the Core Data technology, a subclass of NSManagedObject. To create a model object, define it as you would a basic class and observe the Cocoa naming conventions. For example, begin the names of instance variables, declared properties, and declared methods with a lowercase letter and capitalize the first letter of embedded words.

When you implement your model subclass, you should consider the following aspects of class design:

Sample Code Projects

  • TheElements
Did this document help you? Yes It's good, but... Not helpful...


Last updated: 2010-08-03