我在故事板中设计了带有静态单元格的TableView。
我想获取代码中单元格的值。
NSMutableArray* questions = [[NSMutableArray alloc] init];
for(int i=0; i<3; i++){
SurveyCell* qCell = (SurveyCell*)[self.tableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:i]];
SurveyCell* aCell = (SurveyCell*)[[self tableView] cellForRowAtIndexPath:[NSIndexPath indexPathForRow:1 inSection:i]];
NSString* question = qCell.label.text;
NSString* answer = aCell.label.text;
NSDictionary* questionObj = [[NSDictionary alloc] initWithObjectsAndKeys:question,@"question", answer,@"answer", nil];
[questions addObject:questionObj];
}
这里,somtimes qCell和aCell变为null。从静态单元格中获取值的好方法是什么?