什么是“控制器密钥”在Interface Builder中的平均值>检查器>绑定? [英] What does "Controller Key" mean in Interface Builder > Inspector > Bindings?

查看:105
本文介绍了什么是“控制器密钥”在Interface Builder中的平均值>检查器>绑定?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在文档中找不到它们解释所有这些字段及其含义。特别是Controller Key对我来说不清楚。

解决方案

[复制我对另一个问题的答案 ...] / p>

控制器键是您绑定的(控制器对象的属性)的键。模型关键路径是绑定对象可以向模型对象请求更基本的对象(例如字符串或图像)或其他模型对象(即,深入到模型中)的关键路径。



例如:假设在数组控制器中有一个Person对象,每个Person都有一个 name 。将表列绑定到数组控制器,控制器键 arrangedObjects (从而获得模型对象),模型键路径 name (从而获得值对象)。



一个更复杂的例子:假设你有一个Departments的数组控制器。每个部门包含人员(部门的员工)。您可以将People数组控制器绑定到Departments控制器,控制器密钥 arrangedObjects (获取Department模型对象),模型键路径 @ distinctUnionOfObjects.employees (获取Person模型对象),然后将表列绑定到People控制器,控制器键 arrangedObjects ,模型键路径 name



该表格适用于为贵公司工作的人员;如果您有一个单独的潜在雇员表,您也可以为他们创建Person对象,并且他们不会显示在现有员工表中,因为他们不在部门。当你雇用他们,你会将他们添加到一个或多个部门;那么,它们将自动显示在People数组控制器中,因为数组控制器正在监视所有部门的 employees


I can't find in the Docs where they explain all those fields and what they mean. Especially "Controller Key" is not clear to me.

解决方案

[Copying my answer on another question…]

The controller key is the key for the (property of the controller object) you're binding to. The model key path is the key path by which the bound object can ask the model objects for more basic objects, such as strings or images, or for other model objects (i.e., drill down into the model).

An example: Let's say you have a Person objects in an array controller, and each Person has a name. You bind a table column to the array controller, controller key arrangedObjects (thereby getting the model objects), model key path name (thereby getting the value objects).

A more complex example: Suppose you have an array controller of Departments. Each Department contains Persons (employees in the department). You can bind your People array controller to the Departments controller, controller key arrangedObjects (getting the Department model objects), model key path @distinctUnionOfObjects.employees (getting the Person model objects), and then bind a table column to the People controller, controller key arrangedObjects, model key path name.

That table would be for people who work for your company; if you have a separate table of prospective employees, you can create Person objects for them, too, and they won't show up in the table of existing employees because they're not in a Department. When you hire them, you'll add them to one or more Departments; then, they'll show up in the People array controller automatically, because that array controller is observing the employees of all of the Departments.

这篇关于什么是“控制器密钥”在Interface Builder中的平均值>检查器>绑定?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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