How to compare two NSDate objects in objective C

后端 未结 6 1967
隐瞒了意图╮
隐瞒了意图╮ 2020-11-30 00:51

I have objects of Date type.

I want to compare them, and I have written an if condition in the following way:

if (([startDate1 isEqualToDate:[self g         


        
6条回答
  •  一生所求
    2020-11-30 01:26

    I really liked Luke's answer, and it worked like a charm.

    I used something like this:

    If ([enteredDate compare: [NSDate Date]]== NSOrderedSame || NSOrderedDescending)
    {
     //Do Something if the enteredDate is later or the same as today
    }else
    {
    //if the enteredDate is before today's date
    }
    

    I'm not sure if that helps, but just to reiterate what Luke had written.

提交回复
热议问题