Re: Toll-free bridge type at runtime
Re: Toll-free bridge type at runtime
- Subject: Re: Toll-free bridge type at runtime
- From: Ali Ozer <email@hidden>
- Date: Thu, 2 Apr 2009 19:17:15 -0700
One point of the discussion is that there is no need to do this, and
things you think you might want to do the test for are probably invalid.
But, if you wanted to test, you could see if the instance you have
isKindOfClass:[NSCFArray class]. However, this would be fragile,
since "NSCFArray" is not in the public API, and just an implementation
detail. You could try something like
CFArrayRef cfArray = CFArrayCreate(NULL, NULL, 0,
&kCFTypeArrayCallBacks); // Create a temp CFArray
Class cfArrayClass = [(id)cfArray class]; // Get its class
CFRelease(cfArray);
return ([array isKindOfClass: cfArrayClass]); // See if your array
happens to be an instance of the same class (or is a subclass)
...but even this may be fragile and not guaranteed to get you the
result you were expecting. I'd really recommend finding a solution
that doesn't require this test. The transparency of toll-free
bridging should be enough for almost anything you need to do with CF
or NSArrays "on the other side." (Except for those CFArrays which
were created with custom callbacks, which should never be treated as
NSArrays.)
Ali
On Apr 2, 2009, at 6:27 PM, Greg Guerin wrote:
Despite each side presenting its own test that proves its own case,
may I suggest answering the OP's question:
http://lists.apple.com/archives/cocoa-dev/2009/Apr/msg00082.html
The conditions seem pretty clear to me.
Last one to the garden gate is a rotten egg. ;-)
-- GG
_______________________________________________
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