我正在使用Objective-C分布式对象(DO)将数据从一个应用程序(从网络收集数据)共享到另一个应用程序(Quartz Composer中的补丁)。当与远程对象的连接失败时(当我关闭第一个应用程序时),我得到:
5/16/12 8:17:06.373 PM Quartz Composer: *** EXCEPTION IGNORED: connection went invalid while waiting for a reply because a mach port died
在此之后,石英组合物被挂起。即使我把第一个应用程序备份后,它仍然挂起。我想重新连接Quartz补丁。
我正在使用通知中心关闭旧对象,如下所示:
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(connectionDidDie)
name:NSConnectionDidDieNotification
object:theConnection];
现在,我的同事DidDie看起来像这样:
- (void) connectionDidDie
{
NSLog(@"Connection died and we detected it");
[[self proxyObject] release];
[self setProxyObject:nil];
theConnection = nil;
}
我还检查以确保连接仍处于活动状态,就在访问proxyObject的任何部分之前,如下所示:
if ([NSConnection defaultConnection]) { // this line triggers the exception
// access proxyObject
}
我也试过
if ([theConnection isValid]) { // this line triggers the exception
// access proxyObject
}
在这两种情况下,都是触发此EXCEPTION的测试。
当我关闭第一个拥有售卖对象的应用程序时,我该怎么做才能防止Quartz挂起?
答案 0 :(得分:0)
我永远无法找到一种方法来快速关闭DO连接以防止QC(每秒绘制30-60帧)在调用connectionDidDie:之前测试连接(并崩溃)。最后,我决定使用DO,只获取对象的初始副本,然后执行深层副本,然后在没有任何东西试图访问它时终止DO连接。在你深入研究之后,似乎没有那么好的解决方案。 :(