• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Toll-free bridge type at runtime
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: Toll-free bridge type at runtime
      • From: Ryan Joseph <email@hidden>
References: 
 >Re: Toll-free bridge type at runtime (From: Greg Guerin <email@hidden>)

  • Prev by Date: Re: Loading a view controller from a tab bar controller
  • Next by Date: Re: NSData encode decode
  • Previous by thread: Re: Toll-free bridge type at runtime
  • Next by thread: Re: Toll-free bridge type at runtime
  • Index(es):
    • Date
    • Thread