0

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.

Community
  • 1
  • 1
LShi
  • 1,500
  • 16
  • 29

1 Answers1

1

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.

Ken Thomases
  • 88,520
  • 7
  • 116
  • 154
  • Thanks! Now with this Obj-C category, the whole module optimization also works. I tried adding a Swift extension but to no vail. – LShi Feb 06 '17 at 00:22