I can see people suggesting to pass array of values separately for each.
Don't do this it is very poor approach, instead create a single array of NSDictionnaries
, for instance:
_listOfValue =
@[
@{@"Title":@"title 1", @"Min Value":@"0", @"Max Value":@"100", @"Current value":@"50"},
@{@"Title":@"title 2", @"Min Value":@"4", @"Max Value":@"90", @"Current value":@"60"},
@{@"Title":@"title 3", @"Min Value":@"6", @"Max Value":@"70", @"Current value":@"70"}
];
This will make it easy to retrieve the data you need since they are not separated.
In numberOfRowsInSection
you can return [self.listOfValue count]
.
In cellForRowAtIndexPath
or didSelectRowAtIndexPath
you can easily get the dictionnary at the IndexPath
then parse the value of each key.
//Get the specific value
NSDictionnary *valueDict = _listOfValue[indexPath.row];
//read data from value dictionary
valueDict[@"Title"];
//or the old syntax
[valueDict objectForKey:@"Title"];