【问题标题】:NSArrayController sortDescriptors is not workingNSArrayController sortDescriptors 不起作用
【发布时间】:2015-08-07 00:47:52
【问题描述】:

我有一个 NSArrayController (A) 将它绑定到另一个 NSArrayController (B) 并且我正在尝试对 NSArrayController (B) 进行排序但不工作。

这是我的代码:

    NSSortDescriptor *bSortDescriptor = [[NSSortDescriptor alloc]
                                           initWithKey:@"name" ascending:YES];
    self.arrayControllerB.sortDescriptors = @[bSortDescriptor];

你们中有人知道为什么 NSSortDescriptor 不起作用吗?

非常感谢您的帮助。

【问题讨论】:

  • 你的阵列控制器是如何绑定的?

标签: macos cocoa xcode6 nsarraycontroller nssortdescriptor


【解决方案1】:

更改排序描述符后,您需要在数组控制器上调用rearrangeObjects。然后使用dispatch_async 安排您想要操作排序内容的任何代码。

基于my answer here。希望这会有所帮助。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-02-18
    • 1970-01-01
    • 1970-01-01
    • 2011-03-24
    • 2010-12-19
    • 2013-01-14
    相关资源
    最近更新 更多