Backwards compatibility and CFBundleGetFunctionPointerForName
Backwards compatibility and CFBundleGetFunctionPointerForName
- Subject: Backwards compatibility and CFBundleGetFunctionPointerForName
- From: Todd Clements <email@hidden>
- Date: Wed, 12 Nov 2003 16:03:18 -0800
Hi all,
I'm having a bit of trouble trying to ensure backwards compatibility
for my application (using 10.2 features when they are available, but
allowing the program to launch on 10.1). There are only a few
features I'd like to use, so I had planned on just using
CFBundleGetFunctionPointerForName to load function pointers and use
those (this is the best information I could find on Apple's site, but
it may not be the best way to do it.)
For example, if I wanted to use NSProgressIndicator's
setDisplayedWhenStopped, which is 10.2 only, I tried to use the
following code inside a category I made on NSProgressIndicator:
NSBundle *myBundle = [NSBundle bundleForClass:[self class]];
void ((*myFunction)()) =
CFBundleGetFunctionPointerForName((CFBundleRef)myBundle
CFSTR("setDisplayedWhenStopped"));
myBundle seems to be initialized correctly, however, when
CFBundleGetFunctionPointerForName runs, I get an error
*** -[NSCFType _retainedAbsoluteURL]: selector not recognized
I've searched all over trying to find some simple source code to do
this, but haven't had any success (even in the archives). If anyone
can tell me how to do it, I'd be greatly appreciative. In 10.2 and
later you can use weak linking, but that's not available in 10.1. At
this point, even if I didn't want to include 10.1 compatibility, I'd
want to know how because it has frustrated me for quite a number of
hours.
Another question would then be, if I can get the function pointer to
load, how would I use it in Objective-C? Normally we pass messages
such as [self aFunctionName: parameter], but [self (*myFunction):
parameter] wouldn't work in this case, I'm guessing (in fact you get
a "called object is not a function" compile error).
Thanks in advance!
Todd
--
Todd Clements (email@hidden) <
http://toddclements.com>
"Aren't you getting your hopes up?"
"Isn't that what hopes are for?" -- Monk (TV show)
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.