core data - iOS UICollectionView and CoreData -
i'm new ios , still trying wrap head around basics (my newbie disclaimer). i'm starting play persistent data , presenting data uicollectionview.
i can create cells , right number arrays, i'm having issues right number of cells interacting core data. i'll try example clarify: have entity person attributes first name , last name. have 1 person saved. when number of objects in section, 1 object 1 person. number used create # of cells 1 1 person. i'd create 2 cells (one first name , 1 last name) each person, can't figure out. tried putting each entity own section , using arithmetic return 2 * #of entities in section, hat crashes.
this seems rather simple can't figure out?
in numberofsectionsincollectionview::
return 1;
in collectionview:numberofitemsinsection::
return fetcheddata.count*2;
in collectionview:cellforitematindexpath::
person *p = fetcheddata[indexpath.row/2]; // integer division ... cell.textlabel = indexpath.row % 2 ? p.firstname // odd row number :p.lastname; // row number
Comments
Post a Comment