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

問題は、投稿したメソッドの上にあるソース ファイルの早い段階にあると思われます。これを試してください:

ステップ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 警告が再び表示されるまで、投稿したメソッドの上のメソッドから始めて、メソッドごとにファイル内でメソッドを一度に 1 つずつラップします。そうなったら、問題の原因を突き止めたことになります。

于 2012-03-31T15:07:05.397 に答える
1

オブジェクトを返さずにメソッドControl reaches end of non void functionをラップすると、警告が表示されます。non void問題を把握するには、マウスを右クリックして selectを選択しStructureますRe – Indent。コードの構造をより簡単に見つけ出し、何が起こっているのかを知ることができるようになりました。

于 2012-03-31T12:34:17.667 に答える