NSDocument willPresentError(_:) in Swift 4 : Override not called
NSDocument willPresentError(_:) in Swift 4 : Override not called
- Subject: NSDocument willPresentError(_:) in Swift 4 : Override not called
- From: Jerome Krinock <email@hidden>
- Date: Thu, 29 Jun 2017 22:37:14 -0700
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 (email@hidden)
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:
This email sent to email@hidden