If statement with dates

前端 未结 5 758
予麋鹿
予麋鹿 2021-01-16 17:26

what I am trying to do is make a if statement with dates using greater than less than signs. For some reason only the greater than sign works. Here is my code:



        
5条回答
  •  臣服心动
    2021-01-16 18:01

    Here's the gist of a category I wrote on NSDate. I found it made my code more readable.

    https://gist.github.com/nall/5341477

    @interface NSDate(SZRelationalOperators)
    -(BOOL)isLessThan:(NSDate*)theDate;
    -(BOOL)isLessThanOrEqualTo:(NSDate*)theDate;
    -(BOOL)isGreaterThan:(NSDate*)theDate;
    -(BOOL)isGreaterThanOrEqualTo:(NSDate*)theDate;
    @end
    

提交回复
热议问题