Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Objective c 使用未声明的标识符';单元格';在TableViewCell中_Objective C_Uitableview - Fatal编程技术网

Objective c 使用未声明的标识符';单元格';在TableViewCell中

Objective c 使用未声明的标识符';单元格';在TableViewCell中,objective-c,uitableview,Objective C,Uitableview,我不明白我为什么会收到这个消息,以及如何修复它 在我下面的代码中,包含“cell”的每一行都会给我一条消息“使用未声明的标识符‘cell’” 不需要括号。您在第一行中所做的是将单元格键入位置StableViewCellController,而不是声明它。使用LocationsTableViewCellController*单元格=。另外,如果您使用的是dequeue,您可能需要添加一个cell==nil条件来确保这一点。有时可能会崩溃。 static NSString *CellIdent

我不明白我为什么会收到这个消息,以及如何修复它

在我下面的代码中,包含“cell”的每一行都会给我一条消息“使用未声明的标识符‘cell’”


不需要括号。

您在第一行中所做的是将
单元格
键入
位置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];