iphone - What is the best way to organize a group of groups in Obj-c? -
I have an unusual problem where I have a list of fruits (apple, orange, banana, grapes, etc.) For example, they can be organized into smaller groups:
Group 1: apple, green-low, pineapple group 2: grapes, banana, strawberry, apple group 3: orange, grapes, GreenApple
Each group is then associated with the value then group 1-> 9.99, group 2-> 15.99 etc.
and then later when a list If they are given, then they need to match with the existing groups, and if no one is found, then make one if someone is present, then the price Return
What is the best way to do this? Actually the association should be an NSDictionary, but the key seems to be an array. The problem occurs when I can create a key when given some input? Do I have to resort to keeping things in alphabetical order to be keys compatible? But then this approach will not be very good when the names include symbols ($ apples etc.)
What will be your attitude?
use a NSSet
a NSArray
Instead of (the sets are anarchied lists, and it seems that you have met here). However, I'm not sure when using the NSDictionary
key, the indicator will use the [NSSet isEqualToSet:]
(or whatever is called) method instead of equality, So that you have to implement your own check-in method.
Comments
Post a Comment