Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Learn Cocoa On The Mac (First Edition) –-> code updates for Xcode 4.6.3 (IMHO)

Chapter 10 – Windows and Menus and Sheets

Page 206, “Loading a Nib With NSWindowController” paragraph


The code inside the loadEasyWindow: method and also the EasyWindow nib file must be modified as follows, in order to work with the recent (as of august 2013) version of Xcode and Objective-C:

code:
  • add the easyController object to a mutable array (i called it controllers) in order to avoid its automatic release at the end of the method and so avoiding the premature deletion of the new window (Easy Window). Just place the array declaration** somewhere in the app delegate class, in the public or private interface (private would maybe make more sense) and then add the following line to the loadEasyWindow: method: [self.controllers addObject:easyController];
EasyWindow nib file:
  • set the File's Owner class to NSWindowController (using the identity inspector);
  • set the window outlet of the File's Owner to the window in the EasyWindow nib file (ctrl-drag from the File's Owner icon to the window).
** Don't forget to actually instantiate the array! Do that in its getter or in the applicationDidFinishLaunching: method, for example.

Comments

  • edited August 2013

    Chapter 10 – Windows and Menus and Sheets

    Page 207, “Subclassing NSWindowController” paragraph


    Same solution suggested for page 206 in the previous post.
Sign In or Register to comment.