NSFetchedResultsController基于计算的属性分为几部分 [英] NSFetchedResultsController Separated into Sections based on Calculated Attribute
问题描述
是否可以基于方法的输出创建 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屋!