objective c - Non-Core Data data in a Core Data-backed UITableView -


take @ music.app (or ipod.app). root albums view has "all songs" row. root songs view has "shuffle" row. root playlists view has "add playlist..." row. static data mixed in same uitableview (presumably) core data data. i'm wondering how apple achieved this.

i've tried 2 different approaches, both failed. music.app, views have uiseachbar in tableheaderview. first attempt kept track of how many "static" rows had , adjusted indexpath provided various uitableview , nsfetchedresultscontroller methods require section , row info. working great until implemented nsfetchedresultscontrollerdelegate methods allow creating, editing , deleting. insertrowsatindexpaths:withrowanimation: method (and similar) gets tripped on adjusted indexpaths. default indexpaths don't work either.

my second attempt nest uitableview in tableheaderview of primary uitableview use static rows (and house uiseachbar in it's own tableheaderview). approach didn't make editable stage. uisearchbar ends being overlapped root uitableview's sectionindex scrubber , no longer slides behind uinavigationbar when scrolling short list.

so rather diagnose specific problems i'm asking suggestions on how apple achieves this. fetching data once, caching in nsarray , constructing nested nsarray of sections , rows includes both static , core data rows?

i ran same problem recently. wanted add row @ top of table static content (all songs). got around issue inserting own section section 0, , incrementing core data sections. 0 becomes 1, 1 becomes 2, etc.

- (nsinteger)numberofsectionsintableview:(uitableview *)tableview {     return [_fetchedresultscontroller sections] + 1; }  - (nsinteger)tableview:(uitableview *)tv numberofrowsinsection:(nsinteger)section {     if( section == 0 ) {         return 1;     }     id <nsfetchedresultssectioninfo> sectioninfo = [[_fetchedresultscontroller sections] objectatindex:section-1];     return [sectioninfo numberofobjects]; }  - (uitableviewcell *)tableview:(uitableview *)tv cellforrowatindexpath:(nsindexpath *)indexpath {     // charts     if( indexpath.section == 0 && indexpath.row == 0 ) {         // set custom cell     }     // sets     else {         // set core data cells     } } 

the rest matter of adjusting indexpath sections when removing rows , like.


Comments

Popular posts from this blog

Add email recipient to all new Trac tickets -

400 Bad Request on Apache/PHP AddHandler wrapper -

php - Change action and image src url's with jQuery -