我在这里和其他地方查看了类似的查询,但我似乎仍然无法解决我的问题。
我试图查看存储在数组中可变字典中的日期是否介于其他两个日期之间。生成警告的代码是:
if ( [[[records objectAtIndex:( i )] objectForKey:@"Date"] compare:userStartDate] == NSOrderedDescending && [[[records objectAtIndex:( i )] objectForKey:@"Date"] compare:userEndDate] == NSOrderedAscending ) {
因为它可能是相关的,所以 userStartDate 创建如下:
- (id)initWithArray:(NSMutableArray *)newRecords andWithUserStartDate:(NSDate *)newUserStartDate andWithUserEndDate:(NSDate *)newUserEndDate {
if (self = [super init]) {
[self setRecords:newRecords];
[self setUserStartDate:newUserStartDate];
[self setUserEndDate:newUserEndDate];
}
return self;
}
从代码的另一部分调用:
summariser = [[Summariser alloc]initWithArray:records andWithUserStartDate:[userTimesStartDatePicker dateValue] andWithUserEndDate:[userTimesEndDatePicker dateValue]];
记录本身为:
[record setObject:[datePicker dateValue] forKey:@"Date"];
我希望这很清楚,有人可以提供帮助。
谢谢