我有一个 TableView 控制器,我想用数组中的对象填充它。我正在使用故事板。另外,我不确定是否需要在情节提要的单元原型中放置标签作为占位符类型?
我的 aList 可变数组包含家庭作业类型的对象。在表格的每一行中,我想显示(这些是我的作业模型中已经设置的变量):
-班级名称
-作业标题
-到期日
这是我目前拥有的
表视图控制器.h
@interface AssignmentTableController : UITableViewController
<
AssignmentDelegate
>
@property(strong,nonatomic) Assignment *vc;
@property (strong, nonatomic) NSMutableArray *alist;//array was filled with delegation
@end
表视图控制器.m
#pragma mark - Table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
// Return the number of sections.
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
// Return the number of rows in the section.
return [self.alist count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
Homework *ai = [self.alist objectAtIndex:indexPath.row];
//*******I am not sure what to do from Here******
//*******I need to start displaying 1 object per row,displaying what was stated above***
// Configure the cell...
return cell;
}