i'm having problems comparing a written time stamp file (that is a string of the date when the file was written, IE:"2008-07-21 13:49:53 -0400") with the current date in an if statement. i'm not sure if i can ask if the current date is before or after the date file, because well, dates are more before or after, not greater than or less than... maybe greater than/less than is the same as before and after and i'm looking at this the wrong way, but i just can't seem to get it right.
thoughts?
Code:
NSFileManager *fileManager = [NSFileManager defaultManager];
NSString *installDateFile = @"~/Desktop/dateFile.txt";
installDateFile = [installDateFile stringByExpandingTildeInPath];
NSDate *currentDate = [NSDate date];
if ([fileManager fileExistsAtPath: installDateFile] == NO)
{
NSString *installDate = [[NSDate date] descriptionWithCalendarFormat:nil timeZone:nil locale:nil];
[installDate writeToFile:installDateFile atomically:YES encoding:NSUnicodeStringEncoding error:NULL];
if (currentDate <= installDateFile)
{
NSLog (@"Installed Date File Is In The Future");
}
else
{
NSLog (@"Installed Date File Is In The Past");
}
}
thoughts?