关闭

时间类型排序 NSComparisonResult

288人阅读 评论(0) 收藏 举报
分类:
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
NSDate *date = [dateFormatter dateFromString:[NSString stringWithFormat:@"%@",unreadmail[j][2]]];
NSDate *date1 = [dateFormatter dateFromString:[NSString stringWithFormat:@"%@",unreadmail[j+1][2]]];
 NSComparisonResult result = [date compare:date1];
NSComparisonResult result = [date compare:date1];
NSLog(@"date1 : %@, date2 : %@", oneDay, anotherDay);
if (result == NSOrderedDescending)
{
   //NSLog(@"Date1 is in the future"); //升
   return 1;
}
else if (result == NSOrderedAscending)
{
   //NSLog(@"Date1 is in the past"); //降
   return -1;
}
//NSLog(@"Both dates are the same");
return 0;
0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:6756次
    • 积分:442
    • 等级:
    • 排名:千里之外
    • 原创:39篇
    • 转载:0篇
    • 译文:0篇
    • 评论:0条
    文章分类
    文章存档