简体   繁体   English

NSTreeController的arrangedObjects不响应子元素

[英]`NSTreeController`'s `arrangedObjects` doesn't respond to `children`

In the NSTreeController 's arrangedObjects doc it says: NSTreeControllerarrangedObjects DOC ,它说:

The value of this property represents a proxy root tree node containing the tree controller's sorted content objects. 此属性的值表示包含树控制器的已排序内容对象的代理根树节点。 The proxy object responds to children and descendant(at:) messages. 代理对象响应子代和后代(at :)消息。 This property is observable using key-value observing. 可使用键值观察来观察此属性。

But in the following code the if never hits its body. 但是在下面的代码中, if永远不会触及它的主体。

#import "NSTreeController+RootNodes_m.h"

@implementation NSTreeController (RootNodes_m)

- (NSArray *) rootNodes {
    NSObject *  arranged = self.arrangedObjects;

    if ([arranged respondsToSelector: @selector(children)]) {
        return [arranged performSelector:@selector(children)];
    }
    return nil;
}

@end

I wrote this Obj-C category because in my Swift project I can't turn on "whole module optimization" when I archive the product for release when using a "hack" from this question . 我之所以写这个Obj-C类别,是因为在我的Swift项目中,当我使用此问题的“ hack”来归档要发布的产品时,无法打开“整个模块优化”。 So I tried adding this category, which got me even "worse" result. 因此,我尝试添加此类别,这使我什至“更糟”的结果。

When you're using Objective-C, you should look at the Objective-C version of the docs . 使用Objective-C时,应查看docsObjective-C版本 The page you linked to has a Language selector toward the top-right. 链接到的页面的右上角有一个语言选择器。

In the Objective-C docs, you'll find that the proxy responds to -childNodes , not -children . 在Objective-C文档中,您会发现代理响应-childNodes而不是-children

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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