What I’m Doing:
I’m using CoreData to store information for my app. The most logical way to do this in my instance is to use indexPaths with 3 dimensions, like so:
unsigned indexes[3] = {week, day, position};
NSIndexPath *indexPath = [NSIndexPath indexPathWithIndexes:indexes length:3];
return [self.fetchedResultsController objectAtIndexPath:indexPath];
Firstly, is this OK – or should objects strictly be stored in a two dimensional indexPath?
Where I get stuck:
If it is OK to do this, how can I fix the following method:
- (int)numEventsForWeek:(UInt8)week day:(dayOfWeek)day;
{
id <NSFetchedResultsSectionInfo> sectionInfo = [[[self.fetchedResultsController sections] objectAtIndex:week] objectAtIndex:day];
return [sectionInfo numberOfObjects];
}
This currently crashes because of an unrecognized selector error (the second objectAtIndex:) – But if I take out the second objectAtIndex:, sectionInfo will only give me the number of objects narrowed down to the second index dimension (which is too many objects, I need the number narrowed down to the third dimension).
Why not just use a predicate to filter the result you want to have?
Like a predicate for a specific month, week and weekday.
Can you take a screen shot of your entity?
I might have an other idea…