NSFetchedResultsController基于计算的属性分为几部分 [英] NSFetchedResultsController Separated into Sections based on Calculated Attribute

查看:59
本文介绍了NSFetchedResultsController基于计算的属性分为几部分的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以基于方法的输出创建 NSFetchedResultsController 分成多个部分?例如,如果核心数据模型是一个人,您是否可以将它们分为x代,y代,婴儿潮一代等(当出生日期为核心数据字段,而评估世代的功能为相对琐碎?)。

Is it possible to create an NSFetchedResultsController separated into sections based on the output of a method? For example, if the Core Data model is a person, can you separate them into generation-x, generation-y, baby boomers, etc. (when date-of-birth is the core data field and the function for evaluating the generation is relatively trivial?).

推荐答案

是。在对象模型中创建一个瞬态属性,以便您可以进行适当的计算并将结果分配给它。然后,简单地要求fetchedResultsController将这个属性用于表部分。

Yes. Create a transient property in your object model so you can make the appropriate calculations and assign the result to it. Then simply ask the fetchedResultsController to use this property for the table sections.

这篇关于NSFetchedResultsController基于计算的属性分为几部分的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆