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

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

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