i have custom segmented control can select multiple segments , saves selected indexes selected in array. want each int want titleforsegmentatindex , put titles array or string, struggling set correct loop.
here have right now:
nslog(@"%@", array); prints:
( 0, 1, 4 ) here array:
nsmutablearray *array = [nsmutablearray array]; [self.type.selectedsegmentindexes enumerateindexesusingblock:^(nsuinteger idx, bool *stop) { [array addobject:@(idx)]; }]; and assume need use [segmentcontrol titleforsegmentatindex:int] dont know how incorporate loop.
you need create nsmutablearray , add titles in for ... in loop.
nsmutablearray *titles = [nsmutablearray array]; (nsnumber *index in array) { [titles addobject:[segmentedcontrol titleforsegmentatindex:index.integervalue]]; } you can use plain old for loop, for ... in cleaner , faster.
Comments
Post a Comment