• 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: Accessing IBOutlet From non-IBAction Method
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


References: 
 >Accessing IBOutlet From non-IBAction Method (From: haym37 <email@hidden>)

  • Prev by Date: Re: Accessing IBOutlet From non-IBAction Method
  • Next by Date: Re: Accessing IBOutlet From non-IBAction Method
  • Previous by thread: Re: Accessing IBOutlet From non-IBAction Method
  • Next by thread: Re: Accessing IBOutlet From non-IBAction Method
  • Index(es):
    • Date
    • Thread