【问题标题】:[myArray objectAtIndex:i].property in kvc[myArray objectAtIndex:i].kvc 中的属性
【发布时间】:2023-03-11 07:38:01
【问题描述】:

任何人都知道此代码之前的 kvc 密钥/密钥路径

[myArray objectAtIndex:i].property

【问题讨论】:

    标签: objective-c key-value-coding kvc


    【解决方案1】:

    嗯,最接近的大概是:

    [[myArray valueForKey:@"property"] objectAtIndex:i]
    

    因为数组本身不实现 KVC,所以他们重新定义它以将键应用于元素并返回结果数组。

    【讨论】:

    • 应该是其他方式.. [[myArray objectAtIndex:i] valueForKey:@"property"];
    • 我知道这些方法是否有任何单一的关键路径
    • 没有。不能因为带有数组的 KVC 无法访问单个内容对象。它可以是结果数组(每个对象一个)、数组大小或所有内容对象的聚合值(如最大值、最小值、平均值等)。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-03-17
    • 2012-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多