• 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: NSWindowController Subclassing - windowDidLoad Method
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSWindowController Subclassing - windowDidLoad Method


  • Subject: Re: NSWindowController Subclassing - windowDidLoad Method
  • From: Mike Abdullah <email@hidden>
  • Date: Tue, 2 May 2006 11:31:21 +0100

Glad to have helped. However, you need to either autorelease or release your windowController since the NSDocument will retain it.

i.e.

MyWindowController *windowController = [[[MyWindowController alloc] initWithWindowNibName:@"MyNib"] autorelease];
[self addWindowController: windowController];


OR

MyWindowController *windowController = [[MyWindowController alloc] initWithWindowNibName:@"MyNib"];
[self addWindowController: windowController];
[windowController release];


Mike.

On 2 May 2006, at 06:42AM0, Nelson Santos wrote:

Hi Mike,

Thanks for the response.

After searching for some time, it turns out that your 4th (and, indirectly, the 2nd) point was where the problem lay.

Here is my old document subclass makeWindowControllers method:

- (void)makeWindowControllers
{
MyWindowController *windowController = [[MyWindowController alloc] initWithWindowNibName:@"MyNib" owner:self];
[self addWindowController:windowController];
}


Here is the new method which works:

- (void)makeWindowControllers
{
MyWindowController *windowController = [[MyWindowController alloc] initWithWindowNibName:@"MyNib"];
[self addWindowController:windowController];
}


I should not have used the method with the owner parameter because it was overwriting the file's owner that I set in the Nib file (from MyWindowController to MyDocument).

Thanks for your help!!

Regards,
Nelson




On Apr 30, 2006, at 3:55 PM, Mike Abdullah wrote:

The code should be fine in NSWindowController's windowDidLoad method. You must have something hooked up wrong somewhere. Check:

* All outlets to the text field and button are OK
* The NIB file's owner is your NSWindowController subclass
* The NSWindowController is connected to your window
* The NSDocument knows what it is supposed to be doing properly with regards to window controllers


Mike.

On 30 Apr 2006, at 11:14AM0, Nelson Santos wrote:

Hi all,

I am stuck. I am building a Cocoa document-based application. I have decided to separate my model-controller and view-controller into two classes. A subclass of NSDocument is acting as the model-controller and a subclass of NSWindowController is acting as the view-controller.

In my document nib file, I have several controls including an NSButton and an NSFieldText. What I'd like to do is set the enabled/disabled status of the button and the text value of the text field to certain values before the window/nib is displayed to the user. I tried doing this in NSWindowController's windowDidLoad method, but it didn't work. The problem is that none of the controls have been instantiated yet when this method was called. Another option is to do it in the NSDocument's windowControllerDidLoadNib method which I'm sure will work, but I don't want to put the code in there because I feel that it is a view-controller related thing and belongs in my NSWindowController subclass.

What are my other options? Am I using the best approach? Should I just lump all controller related code into NSDocument subclass and be done with it? I know that splitting the controller logic is a viable design decision, but I can't figure out how to handle this situation.

Thanks to all who respond!

Nelson

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40gmail.com


This email sent to email@hidden



_______________________________________________ Do not post admin requests to the list. They will be ignored. Cocoa-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
  • Follow-Ups:
    • Re: NSWindowController Subclassing - windowDidLoad Method
      • From: Nelson Santos <email@hidden>
References: 
 >Re: NSWindowController Subclassing - windowDidLoad Method (From: Nelson Santos <email@hidden>)

  • Prev by Date: Re: Versioning and CoreData
  • Next by Date: Re: Refactoring tools available for Cocoa / ObjC?
  • Previous by thread: Re: NSWindowController Subclassing - windowDidLoad Method
  • Next by thread: Re: NSWindowController Subclassing - windowDidLoad Method
  • Index(es):
    • Date
    • Thread