why do I get “wait_fences: failed to receive reply” for this code?

[亡魂溺海] 提交于 2019-12-01 11:05:10

Here's how to get rid of the wait_fences error. Change the line where you dismiss the alertView to use animation as follows:

[self.alert dismissWithClickedButtonIndex:0 animated:YES];

I think wait_fences has something to do with view animation states with alert views but it's hard to know for sure. I do think this should eliminate the error msg though. My other answer doesn't directly get rid of the error but I still recommend it. UI actions should be done on the main thread.

There is an obvious problem here. You are posting the notification from the background thread (which is fine) which means the notification handler ModelChangedHandler is being called on the background thread. The handler is then dismissing an alert view which must be done on the main thread. Try changing your code to:

- (void) ModelChangedHandler:(NSNotification *) notification {
    if (![NSThread isMainThread]) {
        [self performSelectorOnMainThread:@selector(ModelChangedHandler:) withObject:notification waitUntilDone:NO];
    }

    else if ([[notification name] isEqualToString:@"ModelChanged"]) {
        NSLog(@"ModelChangedHandler");
        [self.alert dismissWithClickedButtonIndex:0 animated:false];
    }
}

EDIT: was typing too fast, changed answer to reflect the correct UI objects.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!