Re: Replacing objects
Re: Replacing objects
- Subject: Re: Replacing objects
- From: "Shawn Erickson" <email@hidden>
- Date: Mon, 22 Dec 2008 16:55:37 -0800
On Mon, Dec 22, 2008 at 4:30 PM, WT <email@hidden> wrote:
> One is not obligated to use NSProxy to implement the Proxy pattern. I must
> admit not being all that familiar with NSProxy, but having the proxy and the
> object it stands for share the same public API (by being instances of
> subclasses of the same abstract class) seems to me to be a good thing since
> the object and its proxy can be transparently swapped in code. If I
> understand NSProxy correctly, you lose that transparency when you use it,
> because NSProxy and NSObject are in different inheritance trees.
In objective-c any object instance "could" stand in for any other
object as long as it supported the set of messages that would be sent
to it at runtime. No inheritance is needed in this regard.
Also objective-c supports protocols (much like interfaces in Java)
that classes can state they implement ("conforms to"). This allows
disjoint class hierarchies to support the same set of messages with
compile time verification.
An NSProxy sub-class (NSObject for that matter) could be used as a
stand in for any other object instance by leveraging forward
invocation, etc. NSProxy does implement the NSObject protocol so it it
known to act as an NSObject at its core behavior.
-Shawn
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please 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