If statement with dates

前端 未结 5 755
予麋鹿
予麋鹿 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 17:42

    You can't use > or < to compare string objects. That actually compares pointers so we won't get into why > 'works' and < 'doesn't'.

    For this kind of date comparison use NSDateComponents NSDateComponents Reference

提交回复
热议问题