Thanks for your thoughts, Graham and Michael. My irritation is not so much with the "Do you really want to do this? How?" dialogs, but in presenting errors.

Probably I should have given a more concrete example, as I now have [1]. This simplified code from my real app performs a "sync in" to a document of some data from a source on a remote server. For many good reasons (for example, to facilitate other programmatic entries into this process and to allow subclasses to have different implementations), the -makeConnection method is the sixth function in a call stack that begins with the IBAction syncIn:.

Now, what if the network connection fails? I've been presenting the error in a modal dialog, but as I said in my original post, since this network connection failure only affects the current document, I believe that good UI design would want the error presented in a sheet on the document window instead. However, to do so, my code would become a bloody mess.

So I looked again at -[NSDocument presentError:] and saw that it "does not return until the user dismisses the alert". Whoopee!! But upon trying it, I see that gives a free-standing modal dialog box instead of the sheet that I want. Oh, well.

Apple's dialog-box implementation of -[NSDocument presentError:] leads me to believe that Apple has punted on this problem as well. I guess I'll just continue to use the modal dialog -- until I have a free day to consider this challenge.

Jerry

[1] Note: In real life, these methods are in several different classes, but I mashed them together for easier reading.

- (IBAction)syncIn:(id)sender {
    [self syncInWithDeference:BkmxDeferenceAsk
                  ifNotNeeded:YES] ;
}

- (void)syncInWithDeference:(BkmxDeference)deference
                ifNotNeeded:(BOOL)ifNotNeeded {
    // Some Code Here...
    // ....
    for (...]) {
        [internalizer internalizeWithDeference:deference
                                   ifNotNeeded:ifNotNeeded] ;
    }

    // Some Code Here...
    // ....
}

- (BOOL)internalizeWithDeference:(BkmxDeference)deference
                     ifNotNeeded:(BOOL)ifNotNeeded {
    BOOL ok = YES ;

    if (...) {
        // Some Code Here...
        // ....

        if (needDo) {
            ok = [self ixternalizeStartainer:extore
                                     error_p:&error] ;
            // Some Code Here...
            // ....

        }
    }

    return ok ;
}

- (BOOL)ixternalizeStartainer:(NSObject <Startainer> *)source
                      error_p:(NSError**)error_p {
    // Some Code Here...
    // ....

    BOOL ok = [extore readExternalDoingPrereqs] ;
}

- (BOOL)readExternalDoingPrereqs {
    [self setError:nil] ;
    // Some Code Here...
    // ....

    if (ok) {
        ok = [self makeConnection] ;
    }

    if (ok) {
        // Some Code Here...
        // ....

        ok = [self readExternalNoPrereqs] ;
        // Some Code Here...
        // ....
    }

    return (ok) ;
}

- (BOOL)makeConnection {
    // Some Code Here...
    // ....

    if (....) {
        ok = YES ;
    }
    else {
        while (!done) {
            alertReturn = [SSYAlert runModalDialogTitle:nil
                                                message:msg
                                                buttons:
                           button1,
                           [NSString localize:@"cancel"],
                           nil] ;
            if (alertReturn == NSAlertAlternateReturn) {
                // Some Code Here...
                // ....

                break ;
            }

            // Some Code Here...
            // ....
        }
    }

    return ok ;
}

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to