Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
以下代码:
NSDate* date1 = [NSDate date]; NSDate* date2 = [NSDate date]; [date1 compare:date2]; [(NSDate*)[NSDate date] compare:date2]; [[NSDate date] compare:date2];
给我“不兼容的指针类型将'NSDate *'发送到'NSNumber *'类型的参数”用于最后一个日期比较,但不是前两个!
到底是怎么回事???
您需要转换为 NSDate,因为+ (id)date返回的是 id,而不是 NSDate。
+ (id)date