views:

162

answers:

1

Hi, I've had a look through similar queries on here and elsewhere but i still can't seem to resolve my problem.

I am trying to see whether a date stored in a mutable dictionary in an array is between two other dates. The piece of code generating the warning is:

if ( [[[records objectAtIndex:( i )] objectForKey:@"Date"] compare:userStartDate] == NSOrderedDescending && [[[records objectAtIndex:( i )] objectForKey:@"Date"] compare:userEndDate] == NSOrderedAscending ) {

As it may be relevant, userStartDate is created as follows:

- (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;

}

Called from another part of code by:

summariser = [[Summariser alloc]initWithArray:records andWithUserStartDate:[userTimesStartDatePicker dateValue] andWithUserEndDate:[userTimesEndDatePicker dateValue]];

And the record itself as:

[record setObject:[datePicker dateValue] forKey:@"Date"];

I hope this is clear and that someone can help.

Thanks

A: 

I think the problem here is that objectForKey: returns id, so the compiler can't be sure it's an instance of NSDate and triggers the warning.

pgb
That would be a different warning, though.
Peter Hosey