I want to point to a plain ole C-function from Obje开发者_运维技巧ctive-C. Specifically, I am pointing to some OpenGL functions. I want to point to this function from an entry in an NSDictionary.
So is there a way to turn a C function pointer into a SEL?
Thanks,
DougThere may be a better way, but why not have an Obj-C method that will call the plain ole C-Function?
You can then make the Obj-C method the SEL that you call.
You could wrap it in an NSValue
.
[dictionary setObject:[NSValue valueWithPointer:&myFunction] forKey:theKey];
Then when you extract it later, just call -pointerValue
to get a void* pointer back (which you can cast to your function type).
精彩评论