• 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
Re: NSWindowControllers and NSWindow
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSWindowControllers and NSWindow


  • Subject: Re: NSWindowControllers and NSWindow
  • From: Jens Alfke <email@hidden>
  • Date: Mon, 16 Feb 2015 09:37:58 -0800

> On Feb 16, 2015, at 6:17 AM, Dave <email@hidden> wrote:
>
> My initial thought were to have a WindowController:
> LTWMainWindowController that looks after a number of Windows.

Usually you have a separate NSWindowController subclass for each distinct type of window. If the windows share some functionality, put it in a base class and subclass it. Otherwise if you try to do everything with one controller class, you end up with a lot of “switch(_windowType) {…}” stuff, which is a code smell meaning “subclass me!”

As others have pointed out, you almost never subclass NSWindow. The only reason to do that is if you want to do something special to the appearance or behavior of the window frame itself. For example, Chrome has a custom NSWindow class to handle drawing the tabs in the window frame.

One thing no one’s mentioned yet is NSDocument. If your app supports the typical behavior of opening a file into a window, you probably want to use NSDocument, which provides a framework for opening/saving documents, tracking the ‘dirty’ state, working with iCloud storage, etc.

—Jens
_______________________________________________

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


References: 
 >NSWindowControllers and NSWindow (From: Dave <email@hidden>)

  • Prev by Date: Re: NSWindowControllers and NSWindow
  • Next by Date: Re: NSWindowControllers and NSWindow
  • Previous by thread: Re: NSWindowControllers and NSWindow
  • Next by thread: Re: NSWindowControllers and NSWindow
  • Index(es):
    • Date
    • Thread