Re: Toll-free bridge type at runtime
Re: Toll-free bridge type at runtime
- Subject: Re: Toll-free bridge type at runtime
- From: Marcel Weiher <email@hidden>
- Date: Thu, 2 Apr 2009 16:24:17 -0700
NSArray
/ \
NSCFArray MYNSArray
From the Objective-C perspective, there is no such thing as NSArray;
Sure there is.
it is a class cluster,
So apart from being a class cluster (which is also "something" and not
"no thing") it is also an actual class.
and any object that implements the required
methods can be treated as an NSArray; NSCFArray meets that criteria,
as does a custom subclass of NSArray; they are all NSArrays.
Exactly. See diagram above. However, MYNSArray !isa NSCFArray.
Allowing your logic, just about any two classes would actually be
equivalent, because virtually all of them have NSObject as a common
ancestor.
If they implement the same methods and provide the same functionality,
then they *are* equivalent. If it walks like an NSArray and quacks
like an NSArray it *is* an NSArray.
This is not true. Equivalence (under some relationship) is not the
same as identity. Why is this so difficult?
The compatibility that you see and that is confusing you is not due
to the
fact that there is an isa relationship, but due to non-isa
compatibility and
lots of hard-coded work.
Yes, but that hard-coded work is an implementation detail to *provide*
the isa compatibility.
*compatibility* not equality. Once again, the system goes to quite a
few lengths so these *different things* can be used interchangeably in
certain situations. However, that doesn't mean they aren't different
and that you cannot tell them apart. They are different and it is
easy to tell them apart when needed. It is also (fortunately) easy to
treat them the same in many useful situations.
Cheers,
Marcel
_______________________________________________
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