LShi
LShi

Reputation: 1502

NSOutlineView's outlineViewSelectionDidChange(_ notification: Notification) get called twice some times

I have an NSOutlineView bound to an NSTreeController. In the outlineView's delegate, I found that the method outlineViewSelectionDidChange(_ notification: Notification) got called twice when (1) there was a row selected and (2) clicked the title row to collase the group.

The selected rows are both -1. The doc of this method doesn't mention this behaviour.

Is there a way to save one of the two calls?

Upvotes: 1

Views: 282

Answers (1)

P. Banta
P. Banta

Reputation: 1

Did you register for the notification in your delegate?

I observed the same thing you report (outlineViewSelectionDidChange was being called twice) and it was due to adding an observer for NSOutlineViewSelectionDidChangeNotification in my delegate's viewDidLoad. I removed the registration and outlineViewSelectionDidChange was called only once.

Upvotes: 0

Related Questions