KVC与NSArrays的NSArrays [英] KVC with NSArrays of NSArrays

查看:112
本文介绍了KVC与NSArrays的NSArrays的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个数组的数组,我想使用KVC(至少我认为我的 - 它看起来像最直接的方式),但我不知道如何创建单个数组索引的键。我的数组看起来像这样

I have an array of arrays that I want to use KVC on (at least I think I do -- it seems like the most straightforward way) but I can't figure out how to create keypaths for individual array indexes. My array looks like this

NSArray [

NSArray [0,1,2,3],
NSArray [4,5,6,7],
NSArray [8,9,10,11]

NSArray[0, 1, 2, 3], NSArray[4, 5, 6, 7], NSArray[8, 9, 10, 11]

]

我想要做的是获取内部数组中索引3的最大值。看起来像像[outerArray valueForKey:@@ max。[3]]会工作,但我不能弄清楚语法,我的Googling也没有成果。

What I want to do is get the maximum value of index 3 in the inner array. It seems like something like [outerArray valueForKey:@"@max.[3]"] would work, but I can't figure out the syntax, and my Googling has been fruitless as well. Is what I'm trying to do even possible, or should I just write a method to do this manually?

推荐答案

大多数人都是这样做的,期望这是在那里,但KVC真的不允许寻址数组的单个索引。您可以对整个数组或数组的变换(例如, @distinctUnionOfArrays )进行操作,但不能解决单个元素。你必须手工做到这一点。

Most people expect this to be there, but KVC really doesn't allow addressing individual indexes of an array. You can operate on the whole array or transformations of the array (e.g, @distinctUnionOfArrays) but you can't address individual elements. You'll have to do it "by hand," so to speak.

这篇关于KVC与NSArrays的NSArrays的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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