简体   繁体   中英

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM