From the stanford course
NSMutableDictionary *dict = [NSMutableDictionary dictionary];
[dict setValue:[NSDate date] forKey:@"now"];
[dict setValue:[NSDate dateWithTimeIntervalSinceNow:-60] forKey:@"1 minutes ago"];
[dict setValue:[NSDate dateWithTimeIntervalSinceNow:60 * 30] forKey:@"30 minutes from now"];
[dict setValue:[NSDate dateWithTimeIntervalSinceNow:-60 * 60 * 24] forKey:@"24 hours ago"];
[dict setValue:[NSDate dateWithTimeIntervalSinceNow:-7 * 60 * 60 * 24] forKey:@"a week ago today"];
[dict setValue:[NSDate dateWithTimeIntervalSinceNow:365 * 60 * 60 * 24] forKey:@"a year from now"];
for (NSString *key in dict)
{
NSDate *date = [dict objectForKey:key];
NSLog([NSString stringWithFormat:@"Key: '%@' Date: '%@'", key, date]);
}
No comments:
Post a Comment