可可键值绑定:Controller Key的各种选项的解释是什么? [英] Cocoa Key Value Bindings: What are the explanations of the various options for Controller Key?

查看:216
本文介绍了可可键值绑定:Controller Key的各种选项的解释是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我使用Interface Builder将控件绑定到NSArrayController时,绑定检查器中的控制器密钥字段下有各种选项。

When I bind a control to an NSArrayController using Interface Builder, there are a variety of options under the "Controller Key" field in the bindings inspector.

什么arrangeObjects是,我半理解什么选择是,但我想看到一个非常好的解释所有的选项,什么时候使用每一个。该列表包括:selectionIndexes,selectionIndex,selectedObject,sortDescriptors等。我找不到这些选项的良好解释。

I understand what "arrangedObjects" is, and I semi-understand what "selection" is, but I'd love to see a really nice explanation of all the options and when to use each one. The list includes: selectionIndexes, selectionIndex, selectedObject, sortDescriptors, etc. I haven't been able to find a good explanation of these options.

我遇到了问题一个按钮绑定到目标>选择,所以我希望更深入的了解这些控制器密钥可能会帮助我调试我的问题。

I'm having trouble with a button that's bound to target > selection, so I'm hoping a much deeper understanding of these Controller Keys might help me debug my issue.

谢谢!!!


Thanks!!!

推荐答案

这些都很难找到。它们似乎被各种Cocoa书籍甚至是苹果的文档所引用,但我没有看到任何人将它们的解释统一到一个位置。答案是,Apple在每个控制器类的文档中定义它们:

These are tricky to find. They seem to be referenced everywhere by various Cocoa books, and even Apple's docs, but I haven't seen anyone unify an explanation of them into a single location. The answer is, Apple defines them inside the docs for each controller class:


  • NSObjectController( doc

  • NSArrayController( doc

  • NSDictionaryController( doc

  • NSTreeController( doc

  • NSUserDefaultsController( doc

  • NSObjectController (doc)
  • NSArrayController (doc)
  • NSDictionaryController (doc)
  • NSTreeController (doc)
  • NSUserDefaultsController (doc)

这些文档也很有用:

  • Cocoa Bindings
  • Cocoa Bindings Reference

这些Controller对象的继承看起来像这样(这对于发现某些Controller Key选项来说很重要)

Inheritance for these "Controller" objects looks like so (this is important to discover where some of the "Controller Key" options come from):

NSController -> NSObjectController
NSController -> NSObjectController -> NSArrayController
NSController -> NSObjectController -> NSArrayController -> NSDictionaryController
NSController -> NSObjectController -> NSTreeController
NSController -> NSUserDefaultsController

// Note:  NSController is an abstract class (don't worry about it).  It inherits from NSObject.

如果您发现某个类的docs中没有定义Controller Key,超类。下面是每个上述(Xcode 3.2.1,Interface Builder 3.2.1)可用的所有控制器密钥:

If you find a Controller Key not defined in the docs for a particular class, it's probably defined in its superclass. Below are all the Controller Keys available for each of the above (Xcode 3.2.1, Interface Builder 3.2.1):

// **NSObjectController**
canAdd
canRemove
isEditable
selectedObjects
selection


// **NSArrayController**
arrangedObjects
canAdd
canInsert
canRemove
canSelectNext
canSelectPrevious
filterPredicate
isEditable
selectedObjects
selection
selectionIndex
selectionIndexes
sortDescriptors


// **NSDictionaryController**
arrangedObjects
canAdd
canInsert
canRemove
canSelectNext
canSelectPrevious
filterPredicate
isEditable
selectedObjects
selection
selectionIndex
selectionIndexes
sortDescriptors


// **NSTreeController**
arrangedObjects
canAdd
canAddChild
canInsert
canInsertChild
canRemove
isEditable
selectedObjects
selectedNodes
selection
selectionIndexPath
selectionIndexPaths
sortDescriptors


// **NSUserDefaultsController**
hasUnappliedChanges
values

想要,查看控制器类的文档,你会发现它的定义。如果它不存在,它可能在其超类(可能NSObjectController)的文档中定义。

So, find the one on the list you want, look in the docs for that controller class, and you'll find its definition. If it's not there, it's probably defined in the docs for its superclass (likely NSObjectController).

这篇关于可可键值绑定:Controller Key的各种选项的解释是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆