controlTextDidEndEditing Instance method 'controlTextDidEndEditing' nearly matches optional requirement 'control(_:textShouldBeginEditin

More Swift 3 fun! I have a class that overrides controlTextDidEndEditing as such:


  override open func controlTextDidEndEditing(_ obj: Notification) {

    }


According to the headers and everything I can see - this should be correct:

extension NSObject {
    open func controlTextDidBeginEditing(_ obj: Notification)
    open func controlTextDidEndEditing(_ obj: Notification)
    open func controlTextDidChange(_ obj: Notification)
}


However I get the warning:


: Instance method 'controlTextDidEndEditing' nearly matches optional requirement 'control(_:textShouldBeginEditing:)' of protocol 'NSControlTextEditingDelegate'

Accepted Reply

Well that’s odd. You should definitely file a bug about this. Please post your bug number, just for the record.

Are there any drawbacks with implementing both methods? If not, that seems like your workaround.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

Replies

Urgh, informal protocols.

Can you post some more context for this? I tried this out in a simple macOS test project and didn’t get the warning.

import Cocoa

class O : NSObject, NSControlTextEditingDelegate {
    override func controlTextDidBeginEditing(_ obj: Notification) {
    }
}

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

Hi Quinn.


You are testing DidBeginEditing and I'm using DidEndEditing. Shouldn't make much of a difference, but here's the interesting thing. If I just have

  override open func controlTextDidEndEditing(_ obj: Notification) {
...code goes here...
    }


by itself - I get the warning. If I add an empty:

  override open func controlTextDidBeginEditing( _ obj: Notification) {
  }
  override open func controlTextDidEndEditing(_ obj: Notification) {
...code goes here...
    }


No warning…


Context - its a Swift-based private framework for my app.

open class FSRichTextEditorController: NSViewController, FSRichTextEditor, NSMenuDelegate, NSComboBoxDelegate, NSTextViewDelegate, NSTextStorageDelegate, QLPreviewPanelDataSource, NSPopoverDelegate, NSControlTextEditingDelegate {

Well that’s odd. You should definitely file a bug about this. Please post your bug number, just for the record.

Are there any drawbacks with implementing both methods? If not, that seems like your workaround.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

Its a decent workaround. I'll file a bug shortly. I've got quite a few already in RADAR 🙂

I've got quite a few already in RADAR

Betcha I’ve got more (-:

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"