0

i have a NSdatepicker and when i change the year, it changes another NSTextFile´s value to the number of years till now like this:

enter image description here

- ( IBAction)setExp:(id)sender {


NSDateFormatter *df = [NSDateFormatter new];
[df setDateFormat:@"yyyy"];

NSString *TodayString = [df stringFromDate:[NSDate date]];
NSString *TargetDateString = [df stringFromDate: startedPicker.dateValue ];
NSTimeInterval time = [[df dateFromString:TodayString] timeIntervalSinceDate:[df dateFromString:TargetDateString]];

int days = time /60 /60 / 24 /365;


NSString *intString = [NSString stringWithFormat:@"%d", days];

[expLbn setStringValue:intString];
}

but the new data from this action docent get stored in the core data for the NSTextField, if i type in a number in the same textfield the data gets stored.

i tryed http://www.red-sweater.com/blog/229/stay-responsive but can't make that work.

Skovie
  • 197
  • 3
  • 18
  • This line `int days = time /60 /60 / 24 /365;` is just so wrong. There is a whole section in the Date and Time Programming guide about performing calendrical calculations. – Abizern Oct 10 '13 at 21:35
  • okay thanks for the info, but thats not my problem now :-D – Skovie Oct 10 '13 at 21:39

0 Answers0