iphone - NSFetchedResultController multiple limit and sort -
hi have problem table in core data similar this
+-----------------------+ |person | +-----------------------+ |name | |address | |birthdate | |gender | +-----------------------+ in fetchedresultcontroller fetch 2 section gender male , female. , problem want male section sort birthdate , limit 5 rows, in female section want sort name , no limit.
can done in 1 fetchedresultcontroller or need 2 fetchedresultcontroller. or if there way done let me know.
thanks
you can 1 nsfetchedresultcontroller if define own sort method. like:
- (nsstring *) sortby { return (male == self.gender ? self.birthdate : self.name); } and provide sortby in configuration of controller. note, @martin r noted, may not able use objective-c method sorting; if not, define attribute 'sortorder' , compute on object creation.
as limit, not sure, perhaps achieved in tableview:numberofrowsinsection: apple gives example:
- (nsinteger) tableview: (uitableview *) table numberofrowsinsection: (nsinteger) section { id <nsfetchedresultssectioninfo> sectioninfo = [[<#fetched results controller#> sections] objectatindex:section]; return [sectioninfo numberofobjects]; } perhaps return '3' when section 'male' section.
Comments
Post a Comment