Objective c 使用未声明的标识符';单元格';在TableViewCell中
我不明白我为什么会收到这个消息,以及如何修复它 在我下面的代码中,包含“cell”的每一行都会给我一条消息“使用未声明的标识符‘cell’”Objective c 使用未声明的标识符';单元格';在TableViewCell中,objective-c,uitableview,Objective C,Uitableview,我不明白我为什么会收到这个消息,以及如何修复它 在我下面的代码中,包含“cell”的每一行都会给我一条消息“使用未声明的标识符‘cell’” 不需要括号。您在第一行中所做的是将单元格键入位置StableViewCellController,而不是声明它。使用LocationsTableViewCellController*单元格=。另外,如果您使用的是dequeue,您可能需要添加一个cell==nil条件来确保这一点。有时可能会崩溃。 static NSString *CellIdent
不需要括号。您在第一行中所做的是将
单元格
键入位置StableViewCellController
,而不是声明它。使用LocationsTableViewCellController*单元格=
。另外,如果您使用的是dequeue
,您可能需要添加一个cell==nil
条件来确保这一点。有时可能会崩溃。
static NSString *CellIdentifier = @"LocationCell";
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
(LocationsTableViewCellController *)cell = (LocationsTableViewCellController *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
Feed *feed = [_feeds objectAtIndex:indexPath.row];
cell.phraseLabel.text = feed.title;
//cell.detailTextLabel.text = new.place;
//cell.imageView.image = [UIImage imageNamed:@"location.png"];
return cell;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return [_feeds count];
}
LocationsTableViewCellController *cell = (LocationsTableViewCellController *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];