使用组件的无法识别的选择器错误:fromDate:toDate:options

时间:2013-09-16 14:52:29

标签: ios objective-c nscalendar nsdatecomponents

 +(int)weeksBetween:(NSDate *)startDate and:(NSDate *)endDate {

     NSInteger days = [[[NSCalendar currentCalendar] components: NSDayCalendarUnit fromDate: startDate toDate: endDate options: 0] day];

     return (days)/7;
 }

我尝试了多种方式components:fromDate:toDate:optionsQuestion以及其他方式来计算差异,看看我是否可以关闭错误,但我总是得到以下相同的结果:

2013-09-16 08:24:52.268 app[9853:907] -[Day timeIntervalSinceReferenceDate]: unrecognized selector sent to instance 0x1f589720

2013-09-16 08:24:52.270 app[9853:907] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[Day timeIntervalSinceReferenceDate]: unrecognized selector sent to instance 0x1f589720'

我想要几个星期,因为我的方法说但是我一直在试验几天或几个月,因为我看到的代码通常是那种格式(我已经使用选择器几周了,结果相同)。

0 个答案:

没有答案