【发布时间】:2012-04-06 13:50:19
【问题描述】:
对于使用 ARC 的 iOS 5.0 应用程序,我有一个 NSArray 对象,其中包含其他对象的 NSArray。是否可以从内部数组中提取对象列表而无需遍历数组,例如比如说,使用 NSpredicate 或 valueForKeyPath。为了更清楚,我有:
NSArray *objtype1 contains
-id
-NSArray *imageObjs containing imageObjects
-imagetype = 1 <--1st imageObject
imageURL1
-imagetype = 2 <--2nd imageObject
imageURL2
-NSArray *objtype2
-other parameters
我需要提取 imageType = 1 imageObjects 的 NSArray 以进行进一步处理。这可能吗? (我正在查看 NSpredicate 和 valueForKeyPath,但还没有找到任何东西)
【问题讨论】:
-
看起来不像是一个父数组,你真的想让它成为一个具有id、nsarray、nsarray和其他参数属性的类。
-
我同意@sosborn。当你有一个不容易适应 NS 类的数据结构时,那就自己做。给它一个漂亮干净的界面,这样你就不会为了访问它的属性而在商店里乱扔代码了。