I’m putting together a tiny demo project which subclasses NSDocument.  It has 
two targets, identical Cocoa macOS apps except one is in Objective-C and the 
other in Swift.  In the Objective-C target, I override -[NSDocument 
willPresentError:] like this:

- (NSError*)willPresentError:(NSError *)error {
    NSLog(“Presenting!!”)
    ...
    ...
}

and that override is called prior to the display of an error dialog sheet, as 
expected.

In the Swift target, with this code:

    override func willPresentError(_ error: Error) -> Error {
        Swift.print("Presenting!")
        ...
        ...
    }

running the Swift app in the exact same way, presenting the same error dialog, 
this override is never called.  It does not log “Presenting!”, and a breakpoint 
in there never breaks.

A different print(), in deinit(), logs as expected.

Is my syntax correct?  I’m using Xcode 9.0, Swift 4.0.

Thank you!
_______________________________________________

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Reply via email to