Question

Can I call performSelector on c++ class member function somehow?

I'm thinking of creating a dummy objc class that will receive performSelector call, and this dummy class calling the desired c++ member function.

But is there a better way?

(Reason I don't want to just call the method right away is because of threading)

Was it helpful?

Solution

You cannot call an objective c message on a c++ class instance because of fundamental differences in the internals (look into objc_msgSend(), which requires the objective c run-time). You could look into function pointers, or boost C++ libraries like bind or function. Alternatively, you could, as you say, make a wrapper which forwards obj c messages as c++ method calls.

OTHER TIPS

There's no good way to do this. I would create your Objective-C dummy receiver and call your C++ class from there. I've done the same thing in order to receive UI events in C++ classes.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top