Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Creating Core Foundation classes

Since I can't seem to find any documentation on this subject, is it possible to create your own Core Foundation "class"? (classes as in ones that can be used with CFRetain() and CFRelease) I want to take advantage of the polymorphic capabilities and object inspection built into Core Foundation without the overhead of Objective-C or creating my own object hierarchy.

like image 675
James Hu Avatar asked Oct 15 '22 14:10

James Hu


1 Answers

Be forewarned: I believe that Core Foundation doesn't have true inheritance without Objective-C loaded, and with Objective-C loaded you'll get the (minor) associated slowdowns anyway.

There probably won't be any documentation on it, but it might be possible. It certainly won't be clean. Try browsing through the CF-Lite source code (link is for Mac OS X 10.5.7) to get a feel for the framework's implementation.

Note that if the overhead of Objective-C you mention is the overhead of message invocation, there are a great many ways to optimize it (for example, the -instanceMethodForSelector: method). You're very likely to spend more time trying to worm your way into the Core Foundation framework than you are trying to optimize Objective-C code to bring it up to speed.

like image 124
John Calsbeek Avatar answered Oct 18 '22 22:10

John Calsbeek