gpt4 book ai didi

ios - 键值编码说明

转载 作者:行者123 更新时间:2023-11-29 12:49:34 25 4
gpt4 key购买 nike

从 Apple 的文档中,我发现了以下内容:

Setting values using key paths is not the same as setting them using Objective-C properties. You cannot use property notation to set transform values. You must use the setValue:forKeyPath: method with the preceding key path strings.

根据我的理解,我们必须拥有我们的 ivar 的属性才能使用 KVC。

但是从上面这段话来看,好像不是这么说的:

使用键路径设置值不同于使用 Objective-C 属性。您不能使用属性符号来设置转换值。

谁能告诉我为什么?也许我遗漏了什么,因为一直以来我的理解是我们必须有属性才能使用 KVC。

最佳答案

From my understanding, we must have properties of our ivars in order to use KVC.

这是不正确的。 KVC 将使用属性生成的访问器方法,或其他(适当命名的)访问器方法,如果它们存在,但它们不是必需的。如果它们不存在,KVC 将尝试直接访问实例变量。

检查 this Apple ref有关 KVC 如何搜索要更新的 key 的说明。

关于ios - 键值编码说明,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22738059/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com