• 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: Sharing a class' data
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Sharing a class' data


  • Subject: Re: Sharing a class' data
  • From: Cameron Hayne <email@hidden>
  • Date: Fri, 7 Jun 2002 10:44:32 -0400

Jesus De Meyer <email@hidden> wrote:
I wanna make a Cocoa class that is shared in several other classes. But
I don't want to have different instances of the class, but rather would
like to have its data shared. Basically it comes to having class A
shared over other classes but letting class B, C and D reach the data of
class A.
Is this possible in Cocoa? Or would it be just easier to make a header
file and make a struct?

You can just do what you would presumably do with a struct that was to be shared data - you would create the object at the beginning and then pass it as a parameter to the methods that initialize the class B, C, D objects.
Something like:

A *aObj = [[A alloc] init];
B *bObj = [[B alloc] initWithA: aObj];
C *cObj = [[C alloc] initWithA: aObj];
D *dObj = [[D alloc] initWithA: aObj];

... Cameron
--
Cameron Hayne (email@hidden)
Hayne of Tintagel
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Prev by Date: Re: Worker threads and UI threads
  • Next by Date: Re: Sharing a class' data
  • Previous by thread: Re: Sharing a class' data
  • Next by thread: HTML special characters
  • Index(es):
    • Date
    • Thread