0

我在我的应用程序中集成了一个 searchBar。它工作得很好。但是在向我的 tableView 添加新元素后,我的 searchBar 不再起作用。我在此代码块中收到错误消息:

 - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{

static NSString *CellIdentifier = @"Cell";

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; // Here i get: >Control reaches end of non void function<

if (cell == nil) 
{
    cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease];
}
if (searching)
{
    VerwaltungInformation *searchedFormel = [copyListOfFormularies objectAtIndex:indexPath.row] ; //Here i get: >Thread 1: Program received signal "SIGABRT"<

    cell.textLabel.text = searchedFormel.nameFormel;
}
else
{
NSDictionary *dictionaryCell = [listOfFormularies objectAtIndex:indexPath.section];
NSArray *arrayCell = [dictionaryCell objectForKey:@"Formel"];

VerwaltungInformation *cellValue = [arrayCell objectAtIndex:indexPath.row];

cell.textLabel.text = cellValue.nameFormel;
}

return cell;

cellIdentifier 似乎有问题 - 但我无法弄清楚。

谢谢你的帮助!

4

2 回答 2

1

当您在不返回对象的情况下Control reaches end of non void function结束您的方法时会出现警告。non void要找出您的问题,请右键单击鼠标选择Structureselect Re – Indent。现在您可以更轻松地找出代码的结构并找出发生了什么。

于 2012-03-31T12:34:17.667 回答
1

我怀疑问题可能出现在源文件的早期,高于您发布的方法。请试试这个:

步骤1:

@implementation MyClass

@synthesize ...

#if 0

// all of the code that precedes cellForRowAtIndexPath

#endif

 - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

// and so on

编译器是否仍然对 CellIdentifier 发出警告?我的猜测是否定的(尽管您可能会在下面看到各种错误,这些错误与您隐藏在#if #endif 中的符号有关)。

第2步:

移动 #if #endif 对以在文件中一次一个地包装方法,一个方法一个方法,从您发布的方法上方的方法开始,直到 CellIdentifier 警告再次出现。当它发生时,您将找到问题的根源。

于 2012-03-31T15:07:05.397 回答