UIAlertController 同期処理

UIAlertController を使用した際の同期処理がうまくできない。

セマホを使っても、元々メインスレッド上で処理されているらしく、wait待ちすると、ポップアップすら止まってしまう。

どうも VBでいうところの、DoEvents方式しかないようだ。

 

    ....
    [view presentViewController:alertController animated:YES completion:nil];

    while (! finished) {
        // 0.5秒間隔で、finishedしているか、確認しがなら待地合わせる。
        [[NSRunLoop currentRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:0.5]];
    }