问题描述
如果您无法从NSSet中获取objectAtIndex对象,那么如何检索对象?
If you can't get an object with objectAtIndex: from an NSSet then how do you retrieve objects?
推荐答案
是一组的几个用例。您可以枚举(例如使用或NSFastEnumeration),请调用测试对于成员资格,请使用获取成员(非随机),或将其转换为数组http://developer.apple.com/library/mac/documentation/Cocoa/Reference/Foundation/Classes/NSSet_Class/Reference/Reference.html#//apple_ref/doc/uid/20000143-CHDDFHBE\"> allObjects
。
There are several use cases for a set. You could enumerate through (e.g. with enumerateObjectsUsingBlock
or NSFastEnumeration), call containsObject
to test for membership, use anyObject
to get a member (not random), or convert it to an array (in no particular order) with allObjects
.
当你不想要重复,不关心顺序,快速成员资格测试。
A set is appropriate when you don't want duplicates, don't care about order, and want fast membership testing.
这篇关于从NSSet获取对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!