Asad Khan
Asad Khan

Reputation: 11899

unique values of custom object NSString property in nsarray

I have an array which stores custom objects. Objects are of type Venue which have a property defined as name(which contains the names of venue).

Now I want to filter out objects with unique names.

This is how I was trying to do.

NSSet *uniqueVenuesSet = [NSSet setWithArray:[venueArray valueForKey:@"name"]];

NSMutableArray *uniqueVenues = [[NSMutableArray alloc] initWithArray:[uniqueVenuesSet allObjects]];

I get this error when I run this.

    -[NSCFString name]: unrecognized selector sent to instance 0x69a6190
2010-10-24 09:25:31.832 [75790:207]  Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSCFString name]: unrecognized selector sent to instance 0x69a6190'

Can anyone give me a pointer on how to go about it.

Upvotes: 1

Views: 816

Answers (1)

Jacob Relkin
Jacob Relkin

Reputation: 163258

This is because there is at least one NSString object in venueArray.

Make sure that every element in your venueArray is of type Venue.

Upvotes: 1

Related Questions