Why can't NSDate be compared using < or>?

前端 未结 4 1188
無奈伤痛
無奈伤痛 2021-01-14 09:48
NSDate *date = [NSDate date];
NSDateFormatter *dateFormat = [[NSDateFormatter alloc]init];
[dateFormat setDateFormat:@\"MM/dd/yyyy\"];
NSLog([@\"today is \" stringBy         


        
4条回答
  •  半阙折子戏
    2021-01-14 10:01

    in short: because basic operators only work on primitive types for any OBJECT < > != == ... does a basic operation on the POINTER value of this variable

    in c++ those operators can be overwritten in objC and java and other languages you need to use the isEqual function of NSObject

提交回复
热议问题