我正在获取两个日期之间的日期数组..执行此代码时出现错误不知道我哪里出错了:(
我的代码是
NSArray *Dates = [NSArray arrayWithObjects:@"02-02-2012", @"04-02-2012", @"04-02-2012", @"03-02-2012",@"04-02-2010", @"04-02-2012", @"04-02-2011", @"09-02-2012", @"12-02-2012 ", @"11-02-2012", nil];
NSString *startStringDate= @"03-02-2012";
NSString *endStringDate = @"09-02-2012";
//converting NSString to NSDate
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"dd-MM-yyyy"];
NSDate *StartDate = [dateFormatter dateFromString:startStringDate];
NSDate *endDate = [dateFormatter dateFromString:endStringDate];
// output of StartDate is 03-02-2012 08:37:48 +0000
// output of endDate is 09-02-2012 08:37:48 +0000
//using filteredArrayUsingPredicate to fetch date which comes between StartDate and endDate
NSPredicate *findS = [NSPredicate predicateWithFormat:@"(SELF > %@) AND (SELF < %@)", StartDate, endDate];
NSArray *result = [Dates filteredArrayUsingPredicate:findS];
当我运行此代码时,出现错误:[__NSDate length]: unrecognized selector sent to instance 0x982d5a0'
有人可以帮我解决这个问题 提前致谢