Number of instances in NSSearchField

I have an NSSearchField in IB connected to my controller looking in the NSTextView using the delagate methods of the NSTextfield and I can find and store in an array all ranges of a specific text placed in the search box. The question is, how can I show the number directly in the NSSearchField like Apple Text Edit?

enter image description here

What I have tried:

@IBOutlet weak var sf : NSSearchField?

override func viewDidLoad() {
    super.viewDidLoad()

   (self.sf?.cell as! NSSearchFieldCell).cancelButtonCell?.title = "22"
   (self.sf?.cell as! NSSearchFieldCell).cancelButtonCell?.imagePosition = .imageRight
}

override var representedObject: Any? {
    didSet {
    // Update the view, if already loaded.
    }
}

      

+3


source to share





All Articles