Mac上的C ++ / Windows SendMessage()是什么等效的(如果有的话)? [英] What is the equivalent (if any) to the C++/Windows SendMessage() on the Mac?

查看:162
本文介绍了Mac上的C ++ / Windows SendMessage()是什么等效的(如果有的话)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有与 SendMessage 在Mac OS中

讽刺的是,Objective-C中的每个方法调用都相当于SendMessage。 Objective-C是一个消息传递系统。



所以你只需说:

 code> [window myMessage] 

并且myMessage例程将通过传递myMessage到窗口对象并让它处理该方法...



也可能更接近你真正想做的是在组件之间使用通知消息。 / p>

如果你在编译时没有Window对象,编译器可能会抱怨它不知道Window是否可以处理你发送的消息。对于这些情况,您可以使用:

  [window performSelector:@selector(myMessage)] 

此调用的备用版本允许传递对象作为参数。


Is there an equivalent function to SendMessage in the Mac OS?

解决方案

Ironically, every method call in Objective-C is the equivalent of SendMessage. Objective-C is at heart a message passing system.

So you just say:

[window myMessage]

and the myMessage routine will be executed by passing myMessage to the Window object and having it process that method...

It's also possible the closer thing to what you really want to do would be to use Notifications to message between components.

If you don't have the Window object around at compile time, the compiler may complain it doesn't know if Window can handle the message you are sending. For those cases you can use:

[window performSelector:@selector(myMessage)]

There are alternate versions of this call that allow passing objects as parameters.

这篇关于Mac上的C ++ / Windows SendMessage()是什么等效的(如果有的话)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆