0

I have some set of Groups like Color,accessorie,Place, under which they have different data like color has Red, blue, pink etc and so on for other group.

So what should i do ? should i create NSSet or NSArray to keep data, like i did below or Any other good way to do it

For example,

NSSet *color = [NSSet setWithObjects:@"Red", @"Blue", @"Pink"];
NSSet *accessorie = [NSSet setWithObjects:@"Bat", @"Ball", @"Football"];
NSSet *place = [NSSet setWithObjects:@"chicago", @"Sydney", @"Lasvaegas"]

;

Let me know if question is clear Help Appreciated and Thanks in advance :)

DAMM108
  • 970
  • 2
  • 13
  • 27
  • 2
    What are the properties you desire of the "other way" of keeping these values. Why is a set or array not OK? – Hot Licks Jul 16 '13 at 20:29
  • NSArray is ordered NSSet is not ordered, so if you wish to know which element your data is at then i would suggest NSArray if that is not needed then NSSet, it is faster and performs better. Complimentary to this post, http://stackoverflow.com/questions/10997404/when-is-it-better-to-use-a-nsset-rather-than-a-nsarray – A'sa Dickens Jul 16 '13 at 20:34
  • @HotLicks In my app if i go with this approach then i have 7 groups then i have to create 7 NSset or Nsarray, so is it a good approach ? – DAMM108 Jul 16 '13 at 20:34
  • If the collection is static (ie. you're not going to add/remove elements frequently), you can also consider a simple enumeration `typedef enum _Color { Red = 0, Blue = 1, ... } Color;`. – Daniel Martín Jul 16 '13 at 20:37
  • @DanielMartín Yes collection is static – DAMM108 Jul 16 '13 at 20:38
  • Seven is not a big number, in iOS terms. – Hot Licks Jul 16 '13 at 20:51

0 Answers0