[英]NSOutlineView's outlineViewSelectionDidChange(_ notification: Notification) get called twice some times
I have an NSOutlineView
bound to an NSTreeController
. 我有一个绑定到
NSTreeController
的NSOutlineView
。 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. 在outlineView的委托中,我发现方法
outlineViewSelectionDidChange(_ notification: Notification)
在(1)选择了行并且(2)单击标题行以合并该组时被调用两次。
The selected rows are both -1. 所选行均为-1。 The doc of this method doesn't mention this behaviour.
该方法的doc没有提到这种行为。
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
. 我观察了你报告的相同内容(
outlineViewSelectionDidChange
被调用了两次),这是因为在我的委托的viewDidLoad
添加了NSOutlineViewSelectionDidChangeNotification
的观察者。 I removed the registration and outlineViewSelectionDidChange
was called only once. 我删除了注册,并且
outlineViewSelectionDidChange
调用了一次outlineViewSelectionDidChange
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.