Re: Accessing IBOutlet From non-IBAction Method
Re: Accessing IBOutlet From non-IBAction Method
- Subject: Re: Accessing IBOutlet From non-IBAction Method
- From: Camillo Lugaresi <email@hidden>
- Date: Tue, 14 Feb 2006 02:48:46 +0100
On 14/feb/06, at 01:58, haym37 wrote:
I am accessing ipcChangeState from another class like this:
InspectorPanelController *ipc = [InspectorPanelController alloc];
Never do this. You must always use alloc together with an
initializer; eg, [[InspectorPanelController alloc] init]. However, in
this case you probably don't want to allocate a new instance at all.
See below.
[ipc ipcChangeState];
[ipc release];
It does in fact get inside the ipcChangeState method. However,
this is the output in the log:
retain count awakefromnib: 2
title: Inspector
retain count ipcchangestate: 0
here
title: (null)
retain count changestate0: 1
inspectorpanel: Inspector
retain count changestate1: 2
retain count changestate0: 1
inspectorpanel: Inspector
retain count changestate1: 1
How come it cannot access inspectorPanel from ipcChangeState?
Because nobody has connected the outlet. IBOutlets are initialized by
the nib loader for objects that are instantiated from the nib and for
the object passed as the owner of the nib; but when you allocate an
object yourself, all outlets will be nil. In this case, you probably
don't want to allocate a new InspectorPanelController, but to access
the one loaded from your nib.
Camillo
_______________________________________________
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