If you can't get an object with objectAtIndex: from an NSSet then how do you retrieve objects?
An object representing a dynamic, unordered, uniquing collection, for use instead of a Set variable in cases that require reference semantics.
An object representing a static, unordered collection of unique objects.
Creating NSArray Objects Using Array Literals In addition to the provided initializers, such as initWithObjects: , you can create an NSArray object using an array literal. In Objective-C, the compiler generates code that makes an underlying call to the init(objects:count:) method.
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 doesn't have a method objectAtIndex:
Try calling allObjects which returns an NSArray of all the objects.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With