Re: Building an MVC based App for Mac OS X - NOT for iOS
Re: Building an MVC based App for Mac OS X - NOT for iOS
- Subject: Re: Building an MVC based App for Mac OS X - NOT for iOS
- From: Quincey Morris <email@hidden>
- Date: Tue, 28 May 2013 10:28:04 -0700
On May 28, 2013, at 10:01 , YT <email@hidden> wrote:
> I did run a test and created a NEW Project and checked the box "Create a Document-based App"
> AND no Controller files (.h,.m) were automatically generated.
Actually, two controllers *were* generated:
1. The app delegate. This object has the role of a controller, even though it starts out with nothing to do. Its controller behavior comes from code you add to it, as necessary.
2. The NSDocument subclass. These objects are also controllers.
> Which leads to the general mechanical problem of how does one create Controller files (.h,.m)?
A MVC controller is just an object that behaves like a controller. It doesn't have to have "controller" in its name to behave like a controller. It can be of any class, and the class you choose depends on what it's supposed to do.
Keep in mind that the MVC pattern is a very general pattern. A MVC "controller" is not the same as a "view controller". Putting this another way, a view controller is a kind of MVC controller, but not the only kind.
Similarly, a MVC "view" is not necessarily a view. Rather, it's a component of your app design that interacts with the user. It may be implemented as a window, or as a view, or as a window with a hierarchy of views, or something more complex.
Translating a MVC design pattern into an implementation is messier on the Mac than on iOS. That's because the objects used on the Mac grew up over time. iOS's UIViews and UIViewControllers were based on Mac concepts, but tried to unify the loose Mac architecture into something more consistent and rational.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden