我想是这样的:http://iphonedevwiki.net/index.php/CPDistributedMessagingCenterOS X上CPDistributedMessagingCenter的替代方案?
发送和接收同步
进程之间的一些的NSString但CPDistributedMessagingCenter仅适用于iOS版。
有人可以给我建议如何做到这一点?谢谢! ;)
我想是这样的:http://iphonedevwiki.net/index.php/CPDistributedMessagingCenterOS X上CPDistributedMessagingCenter的替代方案?
发送和接收同步
进程之间的一些的NSString但CPDistributedMessagingCenter仅适用于iOS版。
有人可以给我建议如何做到这一点?谢谢! ;)
你考虑过NSDistributedNotificationCenter吗?
我会建议创建一个DistributedNotificationCenter
(服务器),侦听从NotificationCenter
发送的通知。它应该简单地将任何收到的消息(或任何注册的兴趣)转发到对等DistributedNotificationCenters
(在其他进程中运行)。
问题是这些DistributedNotificationCenters
如何“找到”对方。嗯,有多种选择:
DistributedNotificationCenterLocator
服务(服务器)挂接起来,甚至有可能是所有消息的中央中继点(但具有可扩展性的问题)。DistributedNotificationCenterLocator
的端口初始化您的应用程序。DistributedNotificationCenter
如果它是特定于应用程序的 - 也就是说我在“server:port”上,它可以在数据库中注册。即众所周知的查找。我还没有提供的任何代码在这里,但让我知道如果你需要任何指针...
我找到了一个很好的指导作用。 http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/DistrObjects/DistrObjects.html#//apple_ref/doc/uid/10000102-SW1
在这里,我分享我的片断:
服务器:
[NSConnection serviceConnectionWithName:@"your.connection.name" rootObject:self];
客户:
[[NSConnection rootProxyForConnectionWithRegisteredName:@"your.connection.name" host:nil]performSelector:@selector(a_selector_that_server_object_respond_and_return_value)];
我有就可以了的样子。但我想发送消息到另一个进程并等待响应。它不能回复通知 – Qusic 2013-04-24 16:00:16