FROM : Scott Ahten
DATE : Sun Apr 10 19:05:43 2005
On Apr 10, 2005, at 9:24 AM, Dale Gillard wrote:
> On 9 Apr 2005, at 10:52 PM, I wrote:
>
>
>> I've an existing Nib file to which I've added a new NSPanel. That
>> is, I've added an outlet to the IB instance, dragged and connected
>> the instance to the panel, and then added the IBOutlet reference
>> to the .h file using the code, IBOutlet NSPanel *aPanel.
>>
>> But... when I run the project the new panel does not appear when I
>> send it a makeKeyAndOrderFront: message. I've run the app in the
>> debugger and the outlet is nil. Is there something I'm doing
>> wrong? Thanks.
>>
>
> More info: If I send a makeKeyAndOrderFront: message in
> awakeFromNib then the NSPanel is displayed. But if I send the
> message later from a different method the NSPanel does not appear.
> It's like Cocoa is not retaining the outlet?! And it has me
> wondering whether I need to retain the outlet in some way.
>
> In this case I'm launching the app, doing some stuff, and then
> creating anInstance with the [aClass alloc] init] messages. (The .h
> file for aClass contains the outlet pointing to a NSPanel.) I send
> some message to anInstance, including asking it to send its outlet
> the makeKeyAndOrderFront: message to display the NSPanel. Every
> message works fine, and the NSPanel outlet is nil so it fails to
> send the makeKeyAndOrderFront: message.
>
> Why is the outlet being initialised in awakeFromNib, but being
> released before I can create an instance of the class which
> contains the outlet? Any advice would be appreciated. I'm stumped!
Based on your description, I think there are actually two instances
of your class being created.
01. The class you've instantiated in Interface Builder (which
receives the message awakeFromNib)
02. The class you create programmatically ([aClass alloc] init])
IB only wires up classes that are instantiated and saved in your nib
file. Classes you create in code are not automatically connected,
The instance in your nib creates the panel since has a reference to
the panel and receives the awakeFromNib message. The class you create
programmatically does not display the panel since it never receives a
reference to it in the first place. You'll either need to assign the
programmatically created instance a reference to the panel at runtime
or use the instance you've created in your nib.
- Scott
DATE : Sun Apr 10 19:05:43 2005
On Apr 10, 2005, at 9:24 AM, Dale Gillard wrote:
> On 9 Apr 2005, at 10:52 PM, I wrote:
>
>
>> I've an existing Nib file to which I've added a new NSPanel. That
>> is, I've added an outlet to the IB instance, dragged and connected
>> the instance to the panel, and then added the IBOutlet reference
>> to the .h file using the code, IBOutlet NSPanel *aPanel.
>>
>> But... when I run the project the new panel does not appear when I
>> send it a makeKeyAndOrderFront: message. I've run the app in the
>> debugger and the outlet is nil. Is there something I'm doing
>> wrong? Thanks.
>>
>
> More info: If I send a makeKeyAndOrderFront: message in
> awakeFromNib then the NSPanel is displayed. But if I send the
> message later from a different method the NSPanel does not appear.
> It's like Cocoa is not retaining the outlet?! And it has me
> wondering whether I need to retain the outlet in some way.
>
> In this case I'm launching the app, doing some stuff, and then
> creating anInstance with the [aClass alloc] init] messages. (The .h
> file for aClass contains the outlet pointing to a NSPanel.) I send
> some message to anInstance, including asking it to send its outlet
> the makeKeyAndOrderFront: message to display the NSPanel. Every
> message works fine, and the NSPanel outlet is nil so it fails to
> send the makeKeyAndOrderFront: message.
>
> Why is the outlet being initialised in awakeFromNib, but being
> released before I can create an instance of the class which
> contains the outlet? Any advice would be appreciated. I'm stumped!
Based on your description, I think there are actually two instances
of your class being created.
01. The class you've instantiated in Interface Builder (which
receives the message awakeFromNib)
02. The class you create programmatically ([aClass alloc] init])
IB only wires up classes that are instantiated and saved in your nib
file. Classes you create in code are not automatically connected,
The instance in your nib creates the panel since has a reference to
the panel and receives the awakeFromNib message. The class you create
programmatically does not display the panel since it never receives a
reference to it in the first place. You'll either need to assign the
programmatically created instance a reference to the panel at runtime
or use the instance you've created in your nib.
- Scott
| Related mails | Author | Date |
|---|---|---|
| Dale Gillard | Apr 9, 14:52 | |
| Jonathon Mah | Apr 9, 15:12 | |
| Dale Gillard | Apr 9, 15:22 | |
| Dale Gillard | Apr 10, 15:24 | |
| John C. Warner | Apr 10, 17:21 | |
| Dale Gillard | Apr 10, 18:06 | |
| Scott Ahten | Apr 10, 19:05 |






Cocoa mail archive

