How to group fetched result from Core Data, iOS dev -
i have core data entity called "expense", like: entity: "expense" attributes: "date", "category", "amount"..........
my question is possible fetch how many expenses year or year-month? know if fetch based on time period or category, can use nspredicate filter fetched result. "date" attribute in mind should seperated year , month, can group them in sql query. possible directly in fetch? otherwise way fetch whole data nsarray , filters nspredicate.
i have searched days find no direct answer. kinda believe there no direct solution. still think want check out if can provide me better solution coz every developer must have solved problem.
any suggestion appreciated, thank guys :)
============================added======================= moreover, feteched result based "year-month" index-listed in uitableview, far know technique indexed list. i'm provide every array expenses according every indexed "year-month". there better way that?
my thinking based on data structure build to-many relationship, entity(year) to-many entity(year,month,year-month) to-many entity(year-month, date, amount....). maybe bring me convenience when fetch every array indexed uitableview.
you can implement @readonly properties "year" , "month" in expense class , use them in predicate. don't have store these values separatel, compute them in getters using nsdatecomponents.
Comments
Post a Comment