-2

How to implement this issue: When set person birthday date to appear sign of the zodiac? Please help to solve my issue.

NSDateFormatter *dateFormatter = [[NSDateFormatter alloc]init];
[dateFormatter setDateFormat:@"dd-MM-yyyy"];
[_birtDateTextField setText:[dateFormatter stringFromDate:[_datePicker date]]];
John Green
  • 504
  • 2
  • 7
German
  • 137
  • 17
  • 1
    no, I think Astakhoff just doesn't know how to compare and/or initialize NSDates. The same question could have been asked about, say, putting a icon up on a person's birthday relative to Ground Hog day or something just as stupid. – John Green Feb 01 '14 at 17:06

1 Answers1

1

You need to keep the NSDate, not just the formatted date. Now you'll want to compare the date the person entered against the zodiacal dates.

This question, How to compare two NSDates: Which is more recent?, show you how to compare dates. A little bit of cut/paste code from that question is:

    if ([date1 compare:date2] == NSOrderedDescending) {
        NSLog(@"date1 is later than date2"); 
    }

Now you just need to create an NSDate for each sign of the zodiac. I don't know those dates so just google for them. Again, the search function is your friend here. Look at Initialize NSDate with custom date and notice this line:

    [calendar dateFromComponents:components]

Be sure to set the years correctly!

Community
  • 1
  • 1
John Green
  • 504
  • 2
  • 7