Glenncito
Glenncito

Reputation: 930

How do I remove only one of the many values assigned to a key in a Dictionary?

I have a dictionary with an array of potential values for a key. Now I want to be able to remove just one of the values (according to a selection made by the user), but all the examples I find deal with dictionaries that don't contain an array.

Thanks!

Upvotes: 1

Views: 67

Answers (1)

Dan Loughney
Dan Loughney

Reputation: 4677

So you have a NSMutableDictionary whose values are NSMutableArray objects whose items are NSString objects, right? If so,

  1. retrieve the array using the dictionary key

    NSMutableArray *mutableArray = mutableDictionary[key];

  2. then delete the object

    [mutableArray removeObject:stringObject];

Upvotes: 1

Related Questions