aneuryzm
aneuryzm

Reputation: 64864

Is the NSSet iteration needed in this case?

I have a NSSet of object from the same class and I want to get the property value for each object stored in the NSSet, do I always need to iterate through the NSSet ? Or can I somehow create another NSSet containing the properties of the objects only without iterating?

If I have a NSSet of strings, and I need to remove the same substring from all strings in the NSSet, do I need to iterate, or can I create another NSSet with the removed substrings in another way ?

thanks

Upvotes: 1

Views: 323

Answers (1)

user1040049
user1040049

Reputation:

Try calling your NSSet's valueForKey:. It returns a set of the property of every item in your set.

This requires every object in the set to be KVC compliant.

Upvotes: 1

Related Questions