I've a main array (arrayEvents
) contains list of events with fields like, start_date, event_id, event_name, many events can be possible on same date but different times. So I'm taking only unique dates (arrayDates
) to check and compare it with the current date (currentDate
its range from 1st day of month to last day of month) to show event on particular dates. I'm done up to here. Now my problem is that, I need to update arrayEvents
for later comparisons so I am applying the following logic ...but I am in the middle of the sea
and don't know where to go!
for(int i=0;i<[arrayDates count];i++) {
NSDate *obj = [arrayDates objectAtIndex:i];
if([obj isEqualToDate:currentDate]) {
//This date has some events, we've done up to here.
//Now taking indexes of same objects (that's same dates objects) from the arrayEvents
NSIndexSet *indexesOfObjects = [arrayDates indexesOfObjectsPassingTest:^BOOL(id obj, NSUInteger idx, BOOL *stop) {
return [arrayEvents containsObject:obj];
}];
if([indexesOfObjects count] > 1) {
//We found some objects into arrayEvents, now I have to update
//those objects into arrayEvents.
//How to achieve this?
//My plan was to iterate each indexes and make update on arrayEvents
//but I can't do this, as I don't have access to each index from NSIndexSet.
}
}
}
[[arrayEvents objectsAtIndexes:indexesOfObjects]
setValue:[arrayDates objectAtIndex:i] forKey:@"filter_date"];
isn't worked.
Reference, How to indicate index of NSIndexSet object? but doesn't help me.
You can try doing something like this:
or you can use
which ever suits your convenience