문제

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)

도움이 되었습니까?

해결책

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.

다른 팁

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top