// wc here is an NSWindowController
[NSAnimationContext beginGrouping];
[[NSAnimationContext currentContext] setDuration:0.5f];
if (duplication) {
NSPoint origin = initialSize.origin;
origin.y += initialSize.size.height;
origin = [wc.window cascadeTopLeftFromPoint:origin];
origin.y -= initialSize.size.height;
//[[wc.window animator] setFrameOrigin:origin]; // Why setFrameOrigin and cascadeTopLeftFromPoint are not animated?
initialSize.origin = origin;
[[wc.window animator] setFrame:initialSize display:YES];
}
// This block should be invoked when all of the animations started above have completed or been cancelled.
// For not to show the edit window till the duplication animation not finished
[NSAnimationContext currentContext].completionHandler = ^{
if (edit)
[wc editDocument:self];
else
if (fullScreen)
[wc.window toggleFullScreen:self];
};
[NSAnimationContext endGrouping];
В этом случае выполняется завершающий блок, но, к сожалению, он не ждет завершения перестановки окна, вместо этого он немедленно открывает лист редактирования окна и перемещает их вместе.Почему NSAnimationContext completeHandler не работает (иногда)?
Самое странное, что несколько строк выше в том же исходного файла и тот же тип блока сдачи прекрасно работает: -O
Что я здесь отсутствует?