Re: CoreFoundation <==> Foundation?
Re: CoreFoundation <==> Foundation?
- Subject: Re: CoreFoundation <==> Foundation?
- From: Brian Hill <email@hidden>
- Date: Sat, 16 Jun 2001 19:45:12 -0500
On Saturday, June 16, 2001, at 07:32 PM, Deirdre Saoirse Moen wrote:
A couple of quick questions.
If I have existing code which works with CF(*)Refs can I cast them to
NS(*) and expect them to work?
No. CF stuff is not OOP. BTW, that will blow up horribly if you try it.
That's not true. I do it all the time.
With any of the 'property list types' (ie., strings, numbers, dates,
arrays and dictionaries), you can cast their CF(*)Ref to an id and send
a message to it just fine. This has to be in an ObjC file (with an .m)
of course, but it's not a problem.
Like this:
[(id)theCFStringRef fileSystemRepresentation];
You can also treat these same ObjC types as CFTypes in under many
circumstances as well. For example, you can pass an NSString instead of
a CFStringRef, etc...
Note: one thing to pay attention to is that if you store ObjC objects in
a CF-type container (ie., array and dictionary), you should make sure to
use the special 'CFType' callbacks constant when you create the
container, ie., for CFDictionary it's kCFTypeDictionaryValueCallBacks.
One of the reasons that this works, of course, is that on OSX 10.0.x,
the functionality of these property list types is now implemented
underneath by CoreFoundation types. Do a backtrace sometime when you try
to store a nil value in an NSArray and check it out.
Brian
email@hidden
http://personalpages.tds.net/~brian_hill
"Why? I came into this game for adventure - go anywhere, travel
light, get in, get out, wherever there's trouble, a man alone.
Now they've got the whole country sectioned off and you can't
move without a form. I'm the last of a breed."
-- Archibald "Harry" Tuttle, Rogue HVAC Repairman