Hi David,

You should consider the "window" Objective C property to be "owned" by 
NSWindowController and it's confusing to define a Ruby class variable with the 
same name. It should automatically appear as an IB outlet for your 
NSWindowController subclass that you would "hook up" in IB just as you would a 
MacRuby outlet assuming that you instantiate your NSWindowController subclass 
with the same NIB with your NSWindow.

As per the NSWindowController documentation, you would read the window property 
using the method window() or self.window which will first load the window if it 
not already loaded.

You could set the window property using setWindow( window ), but normally you 
have NIB expansion call setWindow.

Similarly NSWindow automatically defines the delegate property that you can 
hook up to your window controller in IB assuming that you instantiate your 
NSWindowController subclass with the same NIB with your NSWindow.

I removed a lot of initialization code from my applications once I better 
understood how NIB file expansion works. You can hook up most of your delegates 
and target actions in IB. You can even initialize static Popup and comboBox 
option lists in IB. However, don't hookup dataSource in IB for NSTableView or 
NSOutlineView because it will attempt to load table data before you get 
awakeFromNib.

Bob Rice

On Dec 3, 2012, at 1:35 AM, david kramf <dakr....@gmail.com> wrote:

> Hi Bob
> My code crashes if I omit the attr_accessor. 
> Can you refer me to instructions of how to configure the IB to link to my 
> controller as delegate (?) . In the examples I have in my book  and ,if I am 
> not mistaken, lectures I viewed in iTunes U ( the Stanford series ), they all 
> used the awakeFromNib as point of initialization .
> Thanks, David 
> On Dec 3, 2012, at 6:24 AM, Robert Carl Rice wrote:
> 
>> Hi David,
>> 
>> A couple of things I notice offhand in you code:
>> 
>> The NSWindowController class defines accessor methods for "window" so you 
>> shouldn't redefine it with the Ruby attr_accessor method. Note: similarly 
>> NSViewController defines accessor methods for "view".
>> 
>> You can configure IB to link the window delegate when the Nib is expanded so 
>> that you don't need to set it in awakeFromNib.
>> 
>> Bob Rice
>> 
>> 
>> On Nov 29, 2012, at 6:50 PM, david kramf <dakr....@gmail.com> wrote:
>> 
>>> 
>>> Hi, 
>>> In the copied below code only the awakeFromNib is executed . Can someone 
>>> explain me what do I do wrong ?  Window is displayed and I expected all 
>>> other methods to be called.
>>> Thanks, David
>>> 
>> 
>> _______________________________________________
>> MacRuby-devel mailing list
>> MacRuby-devel@lists.macosforge.org
>> http://lists.macosforge.org/mailman/listinfo/macruby-devel
> 
> _______________________________________________
> MacRuby-devel mailing list
> MacRuby-devel@lists.macosforge.org
> http://lists.macosforge.org/mailman/listinfo/macruby-devel

_______________________________________________
MacRuby-devel mailing list
MacRuby-devel@lists.macosforge.org
http://lists.macosforge.org/mailman/listinfo/macruby-devel

Reply via email to