• 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: connections and the nib lifecycle
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: connections and the nib lifecycle


  • Subject: Re: connections and the nib lifecycle
  • From: Chris Hanson <email@hidden>
  • Date: Wed, 21 May 2008 20:15:07 -0700

On May 21, 2008, at 9:05 AM, Torsten Curdt wrote:

I have a class that extends NSWindowController.


- (void) test:(NSString*)string
{
   [textField setStringValue:string];

   NSLog(@"textField=%@", textField);

   int ret = [NSApp runModalForWindow:[self window]];

   NSLog(@"textField=%@", textField);


Looking into the test method. Why on earth is the textField nil first and only after the runModalForWindow holds the proper reference??
I've already gotten the awakeFromNib and even the windowDidLoad message!


You should not have received either -awakeFromNib or -windowDidLoad for the particular window controller that is running your window. When you invoke -[NSWindowController window], *that* is when the nib is loaded.

I suspect you have not one but two instances of your NSWindowController subclass. You have MyWindowController specified as the File's Owner of your window's nib file, and I bet you *also* have a separate instance of MyWindowController as an object in the nib file (or in another nib file).

You can determine this by modifying your NSLog statements like this:

  NSLog(@"%@.textField = %@", self, textField);

That will log the description of the object itself, not just the value you care about. I suspect that you will see two different window controllers being created.

  -- Chris

_______________________________________________

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: 
 >connections and the nib lifecycle (From: Torsten Curdt <email@hidden>)

  • Prev by Date: Re: Trying to understand -- please help...
  • Next by Date: RE: fundamental question: how do I call controller methods from other classes?
  • Previous by thread: Re: connections and the nib lifecycle
  • Next by thread: ANN: Step by step introduction to programming with Cocoa
  • Index(es):
    • Date
    • Thread