I have a table view with Contacts. in that when i select the contact that contact has to be added in to another Table:RecentsTable. as recently visited items. for this purposs i have used code like this, it's working but. in case of yesterday it cosidered 24 hours. but iwant to display yesterday items when ever date changed then automatically it was added in to yesterday's list. please guide me.
NSDate *date = self.lastviewed;
double time = [date timeIntervalSinceNow];
NSString *tmpValue = nil;
time *= -1;
if(time < 3600*24) {
tmpValue = @"Today";
}
else {
int div = round(time / 60 / 60 / 24);
// I want solution wth respect to yesterday's date date but not as follows
if(div == 1)
tmpvalue = @ "Yester Day";
if (div >1 && div <7)
//tmpValue= [NSString stringWithFormat:@"%d days ago", div];
tmpValue = @"This Week";
else if(div <30)
tmpValue = @"This Month";
else
tmpValue = @"Earlier";
}
thanks in advance..