NSAlert runModal returning -1002

  • I'm using NSAlert like so:

    NSAlert *alert = [[[NSAlert alloc] init] autorelease];
    [alert setMessageText:@"Some text"];
    [alert addButtonWithTitle:@"Yes"];
    [alert addButtonWithTitle:@"No"];
    NSInteger foo = [alert runModal];
    NSLog(@"Runmodal returns: %i", foo);

    Usually I get the expected return code (1000 for the default "Yes"
    button and 1001 for "No", as described in the documentation for
    NSAlert). However, if I run this same code when a modal sheet is open,
    I sometimes get a return code of -1002 (yes, negative) no matter which
    button is pressed. Sometimes I get the correct return code, though.
    Any idea why this might happen?

    Thanks,
    Dustin
previous month december 2007 next month
MTWTFSS
          1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
31            
Go to today