How can I make an NSWindowController subclass that automatically uses a particular nib file?
An NSWindowController object expects to be told what nib file to load (through its initWithWindowNib… methods), because it is a generic implementation of the default behavior for all window controllers. However, when you write a subclass of NSWindowController, it is almost always designed to control the user interface contained in a particular nib file, and your subclass would not work with a different nib file. It is therefore inconvenient and error-prone for the client of the subclass to have to tell it which nib file to load. This is easily solved by overriding the init method to simply call the superclass’s initWithWindowNibName: method with the correct nib name. Now clients just use init and the controller has the correct nib file. You can also override the initWithWindowNib… methods to log an error, because no clients should ever try to tell your subclass which nib file to use. This is a good idea for any NSWindowController subclass designed to work with a specific nib file.
NSWindowController expects to be told by someone else what nib file to load (through its initWithNib… methods), because it is a generic implementation of the default behavior for all window controllers. However, when you write a subclass of NSWindowController it is almost always designed to control the user interface contained in a particular nib file, and your subclass would not work with a different nib file.It is therefore inconvenient and error-prone for the client of the subclass to have to tell it which nib file to load. This is easily solved by overriding the init method to simply call super’s initWithWindowNibName: with the correct nib name. Now clients just use init and the controller has the correct nib. You can also override the initWithNib… methods to log an error, because no clients should ever try to tell your subclass which nib file to use. This is a good idea for any NSWindowController subclass designed to work with a specific nib file. You should only not do this i
Related Questions
- I offer a service whereby clients calls are automatically screened against the TPS if the number dialled is on the TPS file. Do I have to pay a Royalty Fee?
- Does NaviPlan save the changes to the client file automatically and what happens to the work when NaviPlan is closed?
- How can I make an NSWindowController subclass that automatically uses a particular nib file?