如何在Objective-C中快速搜索对象数组 [英] How to quickly search an array of objects in Objective-C

查看:95
本文介绍了如何在Objective-C中快速搜索对象数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果属性的类型为字符串,那么Objective-C中是否有一种方法可以通过包含的对象的属性来搜索对象数组?

Is there a way in Objective-C to search an array of objects by the contained object's properties if the properties are of type string?

例如,我有一个NSArray of Person对象. Person具有两个属性,NSString * firstName和NSString * lastName.

For instance, I have an NSArray of Person objects. Person has two properties, NSString *firstName and NSString *lastName.

搜索数组以在firstName或lastName属性中的任何位置查找与"Ken"匹配的所有人的最佳方法是什么?

What's the best way to search through the array to find everyone who matches 'Ken' anywhere in the firstName OR lastName properties?

推荐答案

简短答案:长答案:谓语编程指南

这篇关于如何在Objective-C中快速搜索对象数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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