Im trying to update a plist file automaticlly if the file is over 24 hours old, but i cant figure out how to compare the two dates.
// get last modification date
NSString *dir = path;
NSDictionary *attributes = [[NSFileManager defaultManager] attributesOfItemAtPath:dir error:nil];
NSDate *date = [attributes fileModificationDate];
NSDate *fileModPlus24Hours = [NSDate dateWithTimeInterval:(24*60*60) sinceDate:date];
Thinking about something like:
if (date > fileModPlus24Hours) {
// update file
}
Any suggestions?
The result of compare can be
NSOrderedAscending,NSOrderedDescendingorNSOrderedSame.And I don’t think your code will work either by comparing
datetofileModPlus24Hours. You should be comparing the current date tofileModPlus24Hoursinstead: