简体   繁体   English

使用委托在C ++类和Objective-C类之间进行通信?

[英]Using a delegate to communicate between a C++ class and an Objective-C class?

I have a thread class (C++) instance running. 我有一个正在运行的线程类(C ++)实例。 When the thread has finished its operation, I want to communicate with one of my UIView objects (Objective-C). 当线程完成其操作后,我想与我的一个UIView对象(Objective-C)进行通信。 Would this be possible via a delegate? 通过代理可以做到这一点吗?

Yes, why wouldn't it be? 是的,为什么不呢?

When compiling in Objective-C++ mode (.mm file extension) you can freely mix Objective-C, C and C++ code, classes and objects. 在Objective-C ++模式(.mm文件扩展名)中进行编译时,您可以自由地混合使用Objective-C,C和C ++代码,类和对象。

Just make sure to perform any GUI stuff on the main thread. 只要确保在主线程上执行任何GUI内容即可。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM