Thursday, February 20, 2014

NSAlert how to use

//---------------------------
- (void)convertDidFinished:(NSString *) outputPath
{
    // NSWindowWillCloseNotification
    static BOOL runAgain = YES;
   // [saveasPDFBT setEnabled:YES];
    //NSAlert
    if (runAgain == NO) // Suppression button: if user doesn't want to see alert, return
        return;
    NSAlert *alert = [[[NSAlert alloc] init] autorelease];
    [alert addButtonWithTitle:@"Open File"];
    [alert addButtonWithTitle:@"Close"];
    [alert setMessageText:@"Convert Finished"];
    [alert setInformativeText:@"Images had been converted to icns"];
    [alert setAlertStyle:NSWarningAlertStyle];
    [alert setShowsSuppressionButton:YES]; // Suppression button: show it
    // [alert setAccessoryView:myView];  // Accessory view: "my" accessed via an outlet connection
    NSInteger result = [alert runModal];
   
    if ( result == NSAlertFirstButtonReturn ) {
        NSString * onePath=outputPath;
        [[NSWorkspace sharedWorkspace] openFile:onePath];
       
       
        // "Delete" clicked
        //  [self deleteRecord:currentRec];
       
    } else if ( result == NSAlertSecondButtonReturn ) {  // Accessory view: handle user-specified data
        // "Extend" clicked
       
    }
    runAgain = (BOOL)![[alert suppressionButton] state]; // Suppression button: get state of button
    //[alert release];
}

No comments:

Post a Comment