我尝试使用分布式对象在其他进程中显示窗口。 进程A通过显示对话框的进程B的分布式对象方法远程调用。如果我试图等待结果,会发生错误。 该方法看起来像这样:ObjectiveC - 通过分布式对象显示窗口
-(BOOL)showWindow //method invoked through distributed objects
{
dispatch_semaphore_t sem = dispatch_semaphore_create(0);
[object showDialog:^(BOOL result){ //this methods creates and display window
NSLog(@"Block called");
dispatch_semaphor_signal(sem);
}];
dispatch_semaphore_wait(sem, DISPATCH_TIME_FOREVER);
return YES;
}
功能的ShowWindow永远不会结束。如果我评论dispatch_semaphore_wait显示“Block called”并显示窗口。 我检查了不同的变体同步,我尝试使用dispatch_sync或异步运行此代码,但没有任何帮助。
我会帮助你的。 Kon