В моей программе есть 2 NSMutableArray, каждый из которых содержит список элементов. Некоторые стоят более 50 долларов, некоторые - менее 50 долларов. Задача состоит в том, чтобы отобразить эту информацию как часть таблицы. Итак ..
В моей таблице 2 раздела
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 2;
}
Каждый раздел имеет название
- (NSString *)tableView:(UITableView *)
tableView titleForHeaderInSection:(NSInteger)section {
NSString *lSectionTitle;
switch (section) {
case 0:
lSectionTitle = @"Under $50";
break;
case 1:
...
Каждый раздел имеет количество
-(NSInteger) tableView:(UITableView *)tableView
numberOfRowsInSection:(NSInteger)section {
NSInteger count= 0;
switch (section) {
case 0:
count = [[[PossessionStore defaultStore] under50Possessions] count];
break;
case 1:
.....
И, наконец, мы выясняем, что отображать как часть данной ячейки
- (UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"UITableViewCell"];
if (!cell) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"UITableViewCell"]autorelease];
}
Possession *p = [[[PossessionStore defaultStore] allPossessions] objectAtIndex:[indexPath row]];
[[cell textLabel] setText:[p description]];
return cell;
}
Вышеприведенный код ссылается на allPossessions
, который состоит из предметов стоимостью более 50 долларов США и менее 50 долларов США. Я застрял в этой точке.
В этом примере могу ли я узнать, меня ли просят нарисовать ячейку для категории ниже или выше 50 долларов?