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

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -