• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
NSDocument willPresentError(_:) in Swift 4 : Override not called
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Follow-Ups:
    • Re: NSDocument willPresentError(_:) in Swift 4 : Override not called
      • From: Quincey Morris <email@hidden>
  • Prev by Date: Re: file encription/decriptoin iOS
  • Next by Date: Re: NSDocument willPresentError(_:) in Swift 4 : Override not called
  • Previous by thread: How to Correctly Add subviews considering auto layout
  • Next by thread: Re: NSDocument willPresentError(_:) in Swift 4 : Override not called
  • Index(es):
    • Date
    • Thread