Search NSArray for value matching value

后端 未结 8 1165
一生所求
一生所求 2020-11-30 07:52

I have an NSArray of objects, which has a particular property called name (type NSString).
I have a second NSArray of NSStrings which are

8条回答
  •  北海茫月
    2020-11-30 08:29

    The methods most helpful will be:

    filteredArrayUsingPredicate:
    

    and

    indexesOfObjectsPassingTest:
    

    The second one uses a code block, not available on iOS before 4.0

    Both of these will be more efficient than iterating directly.

    There's a good example here: http://developer.apple.com/library/ios/#documentation/cocoa/Conceptual/Blocks/Articles/bxUsing.html

提交回复
热议问题