Re: RS: getting at a class instance created by IB
Re: RS: getting at a class instance created by IB
- Subject: Re: RS: getting at a class instance created by IB
- From: Charles Steinman <email@hidden>
- Date: Mon, 21 May 2007 14:12:18 -0700 (PDT)
Just create an outlet to the instance in the file's owner. I'd suggest working through some basic Cocoa tutorials to get a feel for how things work if this doesn't make sense to you. Here's the trusty old Currency Converter:
http://developer.apple.com/documentation/Cocoa/Conceptual/ObjCTutorial/chapter01/chapter_1_section_1.html
Cheers,
Chuck
----- Original Message ----
From: Roland Silver <email@hidden>
To: Mailing Cocoa List <email@hidden>
Sent: Monday, May 21, 2007 2:00:24 PM
Subject: RS: getting at a class instance created by IB
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?
____________________________________________________________________________________Looking for a deal? Find great prices on flights and hotels with Yahoo! FareChase.
http://farechase.yahoo.com/
_______________________________________________
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