Re: messaging between (un)related objects
Re: messaging between (un)related objects
- Subject: Re: messaging between (un)related objects
- From: Charilaos Skiadas <email@hidden>
- Date: Wed, 9 Mar 2005 00:14:27 -0600
On Mar 8, 2005, at 6:48 PM, Justin Spahr-Summers wrote:
Yes, you are overthinking it. Just have Class B maintain a reference
to A, and create a method in A to handle this transfer. Notifications
in this instance have unneeded overhead.
Or if you are really fortunate and you only need one "shared" instance
of the class A, you can implement it as a shared class instance and
refer to it through something like [[classA sharedClassInstance]
takeCareOfDictionary:aDictionary], without needing to keep a reference.
I would say, depending on the particular case under consideration, I
could see merits for all three options, but without knowing more I
can't really say. The real question for me, with my very limited
experience, would be what should/would happen if A gets deallocated
before receiving the dictionary from B? To ensure that would not
happen, you would need to have B retain A, which probably might be the
wrong thing to do, or to make sure that A never gets allocated.
If you think that the two classes really have no reason for knowing
about each other, then I would go with notifications. If one of the
classes should know about the other, then the reference method would be
my preference.
Just my 5c.
Haris
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden