I’m working on an iPhone app which graphs a large database, accessed through core-data, in a line-chart. I’m using a tile-based approach to rendering this graph. The distance between datapoints is irregular.
Each tile uses a predicate to retrieve the data that is relevant for that tile:
NSPredicate* predicate = [NSPredicate predicateWithFormat:@"creationDate > %@ AND creationDate < %@",tileBeginDate, tileEndDate];
[request setPredicate:predicate];
NSMutableArray *result = [[managedObjectContext executeFetchRequest:request error:&error] mutableCopy];
I have a problem when drawing the lines between datapoints residing in different tiles, since the drawing of this line requires a datapoint outside of the range of the tile.
Ideally, I would want to be able to get one datapoint beyond the requested range in core data. Is there any way to do this? If not, any other suggestions?
One of those classical cases where writing down the problem actually solves it. In this case unfortunately some minutes after actually posting it. Sorry.
The solution is simple: I just add two more predicates, one to retrieve the datapoint before and one to retrieve the datapoint after the requested data-range, and then I merge the arrays together.