gpt4 book ai didi

objective-c - NSTreeController addChild : does not call newObject but add: does (Class/Object mode)

转载 作者:行者123 更新时间:2023-12-03 17:52:55 25 4
gpt4 key购买 nike

我注意到我的子类 os NSTreeController 仅在调用 add: 方法时才运行 newObject,但从不调用 addChild:

我找到了this thread讨论同一个问题。虽然在本例中用户在核心数据模式下使用树 Controller ,但我设置为使用特定的类(对象模式)。

addChild: 不使用 newObject 方法可能是什么原因?

如果 newObjectadd: 调用,我认为它没有理由不适合 addChild:。我在 Apple 的 SourceView 演示应用程序中通过用子类替换 OutlineController 并将按钮连接到 add:addChild: 来确认此行为 - 再次仅 add: 调用newObject。我发现这种行为真的很奇怪。

最佳答案

找到answer in the docs :

The add: and insert: actions use the newObject method to create the object that is added to the collection. In object mode the addChild:, and insertChild: create objects of the class specified by objectClass, but do not use the newObject method to do so.

至少它说事情就是这样。尽管它与类引用相矛盾。他们忽略了解释为什么会是这样。

关于objective-c - NSTreeController addChild : does not call newObject but add: does (Class/Object mode),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20454217/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com