0

I am working on an application for the iPhone in which I want to get a start and end date for a Zodiac sign to display on the label. I am not sure how to store this info. I was thinking to store it in Core Data but that could be slow traversing it every time. My other idea is to have a NSDictionary of arrays for each sign. For example

self.zodiacSignsDates = [[NSDictionary alloc]initWithObjectsAndKeys:
                             [NSArray arrayWithObjects:@"December 22",@"January 20",nil], @"Capricorn", 
                             [NSArray arrayWithObjects:@"January 21", @"February 18",nil], @"Aquarius"
                             ,nil];

I might also use this NSDictionary later on to figure out zodiac sign for a birth date.

Please let me know what you think on on how to storing such data

Thanks!

Mick MacCallum
  • 129,200
  • 40
  • 280
  • 281
Yan
  • 3,533
  • 4
  • 24
  • 45
  • See this post http://stackoverflow.com/q/1072848/716216 – Mick MacCallum Apr 21 '12 at 17:30
  • Thanks for the reply. I have the code on how to calculate the sign from a date. I would like to know a good way of storing the ranges for each zodiac sign. – Yan Apr 21 '12 at 17:33
  • Well considering this is a pretty small amount of data, NSUserDefaults should do you well. – Mick MacCallum Apr 21 '12 at 17:34
  • Let me give you a bigger picture if you don't mind. I already have core data database with people in it and their birth day stored as date and zodiac sign as string. I also have a zodiac class with class methods that return sign for date and few others. Would it be better to have sign table that will have a relationship with people table or just have a sign stored as a string and dates stored in the zodiac class in a dictionary? Thanks! – Yan Apr 21 '12 at 17:47
  • I think saving as strings would be the way to go. – Mick MacCallum Apr 21 '12 at 17:52

1 Answers1

1

Posting this as an answer, because of many comments. In addition: wouldn't it be enough to just store the last day of the period in an array the same length as the zodiacs?

var signs = ["Capricorn","Aquarius", ... ];
var lastDay = ["01-20", "02-18", ... ];

last one, i promise. if you want to keep those english strings, you could do this: (since I assume, you already have a list of zodiacs around)

var dates = [["December 22","January 20"],["January 21","February 18"],[etc,etc] ];

and then

private String[] getFromTo( string zodiac ){
   var idx = signs.indexOf(zodiac);
   return dates[idx];
}
mindandmedia
  • 6,800
  • 1
  • 24
  • 33
  • Thanks! I would like to have a method which returns the start and end of one zodiac signs. I think this way would be quicker to access this info. – Yan Apr 21 '12 at 18:15
  • I am not up to date with my astrology, but you could event get away with just storing the day since there are 12 zodiacs (still, or again, right?) and writing a small method to calculate the strings, but a dictionary will do just fine as well. – mindandmedia Apr 21 '12 at 18:23
  • Thanks again for your response! I will try to work with dictionary see where it takes me. They did find a 13th sign but i still believe in 12 :) – Yan Apr 21 '12 at 18:29