Re: Executing methods in one class from within another
Re: Executing methods in one class from within another
- Subject: Re: Executing methods in one class from within another
- From: Cameron Hayne <email@hidden>
- Date: Wed, 12 Jun 2002 00:40:17 -0400
On Tuesday, June 11, 2002, at 10:40 pm, cocoa-dev-
email@hidden wrote:
myClassA doesn't, at this stage, 'possess' an
instance of myClassB, and neither vice versa, so I have problems having
the two accessing values from each other if I do not have some central
switchboard widget that allows me to get hold of one from within the
other.
It sounds like you are saying that your two classes don't "know about"
each other.
In that case, it is impossible (in fact it is nonsensical) for them to
get information form each other.
You need to hav the two classes know about each other or else have some
master class which intermediates the communication.
Example:
The class 'House" has an instance variable 'address'.
The class 'Person' has an instance variable 'name'.
I create one instance of each of these two classes.
It is not possible for the 'house' instance to find out the name of the
'person' instance because it knows nothing of the 'person' object at all.
Possible resolution is to add an instance variable 'owner' to the class
'House' and set this 'owner' to 'person' when the 'house' instance is
created. (initWithOwner: ...)
Then the 'house' could find out the name of its 'owner' by [owner
name]; (assuming that the class 'Person' implements a 'name'
accessor)
... 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.