0

I don't understand why the panel won't close immediately when i click OK button.

if (NSOKButton == [uploadPanel runModal]) {
    for (int i = 0; i < 10000; i++) {
        NSLog(@"%d",i);
    }
}

Instead, it closes only until all statements in the scope are exacuted.

It is weird that the result turn out the SAME when I change the code into something like this:

if (NSOKButton == [uploadPanel runModal]) {
    NSLog(@"ok");
}

for (int i = 0; i < 10000; i++) {
    NSLog(@"%d",i);
}

By the way, there is NO such problem with NSSavePanel.

Is there any way to solve the problem?

UPDATE1: I have tried the method provided by Abhi Beckert, but still doesn't work :(

if (NSOKButton == [uploadPanel runModal]) {
    NSLog(@"ok");
    [uploadPanel close];
}

for (int i = 0; i < 10000; i++) {
    NSLog(@"%d",i);
}
4

2 に答える 2