如何在核心数据中获取超出请求数据范围的另一个数据点?
我正在开发一个 iPhone 应用程序,它以折线图的形式绘制一个大型数据库,通过核心数据访问。我正在使用基于图块的方法来渲染该图。数据点之间的距离是不规则的。
每个图块使用谓词来检索与该图块相关的数据:
NSPredicate* predicate = [NSPredicate predicateWithFormat:@"creationDate > %@ AND CreationDate < %@",tileBeginDate,tileEndDate];
[请求 setPredicate:predicate];
NSMutableArray *结果 = [[managementObjectContextexecuteFetchRequest:请求错误:&错误] mutableCopy];
在绘制驻留在不同图块中的数据点之间的线时遇到问题,因为绘制该线需要图块范围之外的数据点。
理想情况下,我希望能够获得超出核心数据请求范围的一个数据点。有什么办法可以做到这一点吗?如果没有,还有其他建议吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
写下问题实际上可以解决问题的经典案例之一。在这种情况下,不幸的是在实际发布几分钟后。对不起。
解决方案很简单:我只需添加两个谓词,一个用于检索请求的数据范围之前的数据点,一个用于检索请求的数据范围之后的数据点,然后将数组合并在一起。
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.