ios - Show only some of the objects in an Array -
i want only show of items in array, can't figure out how it.
this code have shows objects in array:
@property (strong, nonatomic) nsarray *springs; @property (strong, nonatomic) nsmutablearray *leafs; - (uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath { static nsstring *cellidentifier = @"standardcell"; uitableviewcell *cell = [tableview dequeuereusablecellwithidentifier:cellidentifier]; spring *spring = [springs objectatindex:indexpath.section]; // 13 objects leaf *leaf = [spring.leafs objectatindex:indexpath.row]; // 30 objects cell.textlabel.text = league.shortname; return cell; }
so show 5 of 30 leaf objects array created, , not show of them. there way that?
(i'm using api pull items array)
thanks help, post specific code or other info needed!
edit added per request:
- (nsinteger)tableview:(uitableview *)tableview numberofrowsinsection:(nsinteger)section { spring *spring = [springs objectatindex:section]; return spring.leafs.count; }
i'm using restkit object mapping.
use [nsarray objectsatindexes:]
(reference) subset of array.
leaf *leaf = [spring.leafs objectatindex:indexpath.row]; // include objects 0-4: nsrange range = nsmakerange(0, 5); nsarray *subset = [leaf objectsatindexes:[nsindexset indexsetwithindexesinrange:range]];
just adjust range
whatever start/length want in subset.
edit: of course subset logic in method have duplicated in numberofrowsinsection:
delegate method, else app throw exception.
Comments
Post a Comment