我有两个Cocoa-GUI-应用程序(用ARC编译,没有沙箱)。
应用程序一具有以下功能:
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
// Insert code here to initialize your application
CommController *cc = [CommController new];
NSConnection *theConnection;
theConnection = [NSConnection new];
[theConnection setRootObject:cc];
if ([theConnection registerName:@"MyServer"] == NO) {
/* Handle error. */
NSLog(@"Could not start server.");
}
}应用程序二具有以下功能:
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
id theProxy;
NSConnection *theConnection;
theConnection = [NSConnection
connectionWithRegisteredName:@"MyServer"
host:nil];
theProxy = [theConnection rootProxy];
[theProxy setProtocolForProxy:@protocol(NetProto)];
}来自第二个应用程序的调用[theConnection rootProxy]永远不会返回。如果我使用废弃的[NSConnection defaultConnection]而不是[NSConnection new],它可以工作。因此,我正在寻找一种非弃用的方法来获取rootProxy。
发布于 2013-03-15 21:28:30
按照Ken Thomases的建议,保持对NSConnection对象的强引用是有帮助的。
发布于 2013-03-14 14:39:44
CommController *cc = [CommController new];
NSConnection *theConnection;
theConnection = [NSConnection new];
[theConnection setRootObject:cc];
if ([theConnection registerName:@"MyServer"] == NO) {
/* Handle error. */
NSLog(@"Could not start server.");
}
[[NSRunLoop currentRunLoop] run];//Start the current runloophttps://stackoverflow.com/questions/15390616
复制相似问题