Hallo,
was ist mein Denkfehler? Ich würde bei diesem Code am Ende die Ausgabe: "The difference is 1 days" erwarten, bekomme aber "0 days":
Alles anzeigen
Sample Projekt hängt an. Hat irgendjemand eine Idee?
Alex
was ist mein Denkfehler? Ich würde bei diesem Code am Ende die Ausgabe: "The difference is 1 days" erwarten, bekomme aber "0 days":
Quellcode
- NSCalendar *gregorian = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];;
- NSDate *today = [NSDate dateWithString:@"2011-02-13 00:25:00 +0100"];
- NSDate *yesterday = [NSDate dateWithString:@"2011-02-12 23:50:00 +0100"];
- components = [gregorian components:NSDayCalendarUnit
- fromDate:today
- toDate:yesterday options:0];
- NSInteger days = [components day];
- NSLog (@"The difference is %ld days", days);
Sample Projekt hängt an. Hat irgendjemand eine Idee?
Alex
The only thing that really worried me was the ether.