Re: Sharing a class' data
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.