Использовать значение индекса в секции строк UITableView - PullRequest
0 голосов
/ 23 мая 2011

У меня есть два класса сущностей:

Module.h

@interface Module : NSObject {

    NSString *moduleCode4;
    NSString *moduleTitle4;
    NSString *credits4;
    NSString *semester4;
    NSMutableArray *assessmentDetails4;
}

AssessmentDetail.h

@interface AssessmentDetail : NSObject {

    NSString *assessmentName4;
    NSString *assessmentType4;
    NSString *assessmentWeighting4;
    NSString *assessmentDueDate4;
}

Я заполнил классы в NSMutableArray.

В моем табличном представлении у меня есть:

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    // Return the number of sections.
    GradeToolAppDelegate * appDelegate = [UIApplication sharedApplication].delegate;
    return [appDelegate.modules4 count];
}

- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {

    // The header for the section is the region name -- get this from the region at the section index.
    GradeToolAppDelegate * appDelegate = [UIApplication sharedApplication].delegate;
    Module *aModule = [appDelegate.modules4 objectAtIndex:section];

    return [aModule moduleCode4];

}

Моя проблема в том, что мне нужен путь к строке индекса из индекса модуля раздела.

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    // Return the number of rows in the section.
    GradeToolAppDelegate * appDelegate = [UIApplication sharedApplication].delegate;
    //Module *aModule = [appDelegate.modules4];
    AssessmentDetail *anAssess = [module.assessmentDetails4 objectAtIndex:section];
    return [anAssess count];
}

Я не могу понять, как получить количество оценок из раздела, может кто-нибудь помочь мне здесь.

Большое спасибо.

1 Ответ

1 голос
/ 23 мая 2011

У вас уже было большинство из них в tableView: titleForHeaderInSection:

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
   GradeToolAppDelegate * appDelegate = [UIApplication sharedApplication].delegate;
   Module *aModule = [appDelegate.modules4 objectAtIndex:section];
   return [aModule.assessmentDetails4 count];
}
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...