我有一些对日期进行操作的代码。为了看看它是否可行,我为 OSX 控制台编写了一个非常简单的程序。它工作正常!但是,我想开始制作一个应用程序,所以我在基于视图的应用程序的函数中使用了相同的代码。但是,我不断收到一条错误消息:“没有已知的类方法 dateWithFormat。” 任何帮助,将不胜感激!
-(id)calc:(int)m with:(int)d andWith:(int)y {
NSDateFormatter *formatter = [NSDateFormatter new];
NSDate *date1 =[formatter setDateFormat:[NSString stringWithFormat:@"%i-%i-%i 00:00:00 +0000",m,d,y]];
NSDate *date2 = [NSDate date];
NSTimeInterval secondsBetween = [date2 timeIntervalSinceDate:date1];
int numberOfDays = secondsBetween/86400;
}