• 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
RS: getting at a class instance created by IB
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RS: getting at a class instance created by IB


  • Subject: RS: getting at a class instance created by IB
  • From: Roland Silver <email@hidden>
  • Date: Mon, 21 May 2007 15:00:24 -0600

Say I have a class Foo created and instantiated by Interface Builder.
What's a good way for other code in my project to invoke instance methods in Foo?


The best I can think of is this:

(1) to have a class variable for Foo:
	Foo* bar;

(2) to have a class method
	+(Foo*)getFoo {
		return bar;
	}

(3) to have an awakeFromNib method in Foo, which executes:
	bar = self;

Then outside the class, a Foo instance method fubar can be invoked by
	[[Foo getFoo] fubar];

Anything simpler?

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Prev by Date: Responding to NSFormatter validation refusal in a table
  • Next by Date: Re: Responding to NSFormatter validation refusal in a table
  • Previous by thread: Re: Responding to NSFormatter validation refusal in a table
  • Next by thread: Re: RS: getting at a class instance created by IB
  • Index(es):
    • Date
    • Thread