简体   繁体   中英

`NSTreeController`'s `arrangedObjects` doesn't respond to `children`

In the NSTreeController 's arrangedObjects doc it says:

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. This property is observable using key-value observing.

But in the following code the if never hits its body.

#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 . 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 . 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 .

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