开发者

Smart way to search an array of arrays

I have an array of arrays with objects 开发者_如何转开发and now want to get all objects for a certain date (which is an object property).

what's the best way to query it?


In this case you have to make a double for-loop with fast enumeration and look into each object.

for(NSArray* anArray in yourArray) {

    for(id aObject in anArray) {
      //compare date
    }

}

Maybe it would be better if you exchange the first array with a dictionary which keys are dates. For each key in the dictionary you store an array with objects whose date is the same as in the dictionary key. With that you won't have to look at each single object.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜