• 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: Two windows in a nib with NSWindowController?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Two windows in a nib with NSWindowController?


  • Subject: Re: Two windows in a nib with NSWindowController?
  • From: Trygve Inda <email@hidden>
  • Date: Thu, 24 Aug 2006 17:34:25 +0000
  • Thread-topic: Two windows in a nib with NSWindowController?

> On Thu, 24 Aug 2006 15:50:53 +0000, Trygve Inda <email@hidden>
> said:
>> I have a nib with two windows that acts as a subclass of NSWindowController.
>> There are two NSWindow*...  progressSheet and destinationSheet
>> I call:
>>
>> - (id)initWithObject:(id)anObject
>> {
>>    self = [super initWithWindowNibName:@"MyNib"];
>>    bridge = [anObject retain];
>>    return self;
>> }
>>
>> Calling:
>>
>> NSApp beginSheet:progressSheet modalForWindow:hostWindow modalDelegate:self
>> didEndSelector:@selector(sheetDidEnd:returnCode:contextInfo:)
>> contextInfo:nil];
>>
>> Only works if window is set to progressSheet in the nib. And if so then
>> there is no way to make destinationSheet work in a similar way.
>>
>> Calling [self setWindow:progressSheet]; does not work either.
>>
>>
>> Do I need to not be a subclass of NSWindowController?
>>
>> If I make it a subclass of NSObject, how do I init my nib... Somehow replace
>> [super initWithWindowNibName:@"MyNib"]; so that my two IBOutlet for the
>> NSWindow* get connected?
>
> It is not necessary that the file's owner of a secondary nib be an
> NSWindowController. It is a good idea, though if:
>
> (1) The nib has one main window and using an NSWindowController will make
> management of that window easier (which is often the case).
>
> (2) You intend to "close" the nib. This is because an NSWindowController has
> a magic property where when you finally release the NSWindowController it
> cleans up the nib and releases all the associated memory.
>
> With that out of the way, let me explain something about how opening a
> secondary nib works. The "File's Owner" in a nib is a proxy. It is like a
> kind of costume - clothing without any human being inside it. When the nib
> opens, a real instance (the actual owner of the file) steps inside this
> costume. Presuming you have not lied to IB about what kind of thing the
> owner will be, it will "fit" inside this "costume" perfectly. :)
>
> Now, this costume can be any costume you like. So let's say it is MyObject,
> which has two NSWindow outlets named progressSheet and destinationSheet. So,
> in IB, drag MyObject.h from Xcode into the IB main window for this nib, so
> that it knows what a MyObject is. Now set the File's Owner's custom class to
> MyObject (thus you are saying what kind of costume it is). Presto, now the
> File's Owner has those outlets! So control-drag to hook them to the actual
> progressSheet and destinationSheet windows.
>
> Now when you open the nib with an actual MyObject instance as owner, its
> progressSheet and destinationSheet outlets are set to point to the
> progressSheet and destinationSheet windows. So now you have pointers to the
> window objects in question, and can do with them whatever you like.

I get that, but when it was a subclass of NSWindowController and window
pointed to destinationSheet, even though I also had an outlet to
progressSheet, it would not open.

I have since changed it to a subclass of NSObject and it seems to work.

Trygve


 _______________________________________________
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: Two windows in a nib with NSWindowController?
      • From: Matt Neuburg <email@hidden>
References: 
 >Re: Two windows in a nib with NSWindowController? (From: Matt Neuburg <email@hidden>)

  • Prev by Date: Help Button
  • Next by Date: iTunes and AppleScript
  • Previous by thread: Re: Two windows in a nib with NSWindowController?
  • Next by thread: Re: Two windows in a nib with NSWindowController?
  • Index(es):
    • Date
    • Thread