• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Managing different views for the same window
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Managing different views for the same window


  • Subject: Managing different views for the same window
  • From: "John A. Debay" <email@hidden>
  • Date: Sun, 15 Jun 2003 18:13:43 -0500

Hi,

I'm trying to write a document-based application that will have one main window, and that main window will have different views that will be swapped in and out. This will be similar to what Sherlock or Watson do, or similar to OS X's System Preferences, an application's preferences window, or lots of other examples. I have the code working fine for switching the NSViews themselves in and out and resizing the window correctly.

The question I have is related to managing the code that controls these individual views, and specifically about the window controllers that will manage them. There are a number of ways I can imagine doing it, but I'm wondering if there is an established method of implementing this. I have looked everywhere on the web and have not come across any discussion of how this behavior is typically implemented.

The obvious solution is to have one huge controller class, with outlets and actions for every control on every view in the entire application. This is easy to implement, but cumbersome to maintain and generally awkward to deal with. So I'm trying to come up with a design that is more compartmentalized and flexible, and am not quite sure which way to go. I'm now thinking of keeping one base class, and creating one subclass for each view. I would just set controller for the initial view as the File's Owner, create instances of the others in the document nib file, link up the outlets and actions for the controls in each view to their respective controller instances, and keep common code like switching between views, managing the toolbar, etc., in the base class.

Would this work? I'm definitely not married to this solution, and am more interested in discovering if, as I stated in the beginning, there's some standard solution to this problem. Seeing as how there are many threads about switching views in a window, it would seem as though many people have come across this problem before. Yet I can't find anything on it in the archives. Admittedly, I am new to Cocoa programming and Objective-C (but not new to programming itself), so it is very possible I'm missing something glaringly obvious or am trying to solve a problem that's not really there (avoiding a single monolithic window controller class). If anyone can provide some advice or insight, it would be much appreciated.

Thanks,
John
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Prev by Date: Re: Subclass
  • Next by Date: Custom frameworks and linking - SOLVED!
  • Previous by thread: Re: Registering File Types or Icons
  • Next by thread: Custom frameworks and linking - SOLVED!
  • Index(es):
    • Date
    • Thread