Use index value in row section UITableView
I have two entity classes:
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;
}
I have populated the classes within an NSMutableArray.
In my Table View I have:
- (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];
}
My problem is that I need the index row path from the module index of the section.
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
// Return the number of rows in the section.
GradeToolAppDelegate * appDelegate = [UIApplication sharedApplication].delegate;
//Module *aM开发者_如何学Codule = [appDelegate.modules4];
AssessmentDetail *anAssess = [module.assessmentDetails4 objectAtIndex:section];
return [anAssess count];
}
I can't understand how to get the number of assessments from the section, can anyone help me out here.
Thanks a lot.
You already had most of it in tableView:titleForHeaderInSection:
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
GradeToolAppDelegate * appDelegate = [UIApplication sharedApplication].delegate;
Module *aModule = [appDelegate.modules4 objectAtIndex:section];
return [aModule.assessmentDetails4 count];
}
精彩评论