2012-03-31 18 views
0

私は自分のアプリケーションにsearchBarを統合しました。それはうまくいった。しかし、テーブルビューに新しい要素を追加した後は、searchBarはもう機能しません。 cellIdentifierに問題があるようです新しいオブジェクトを追加した後に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; 

- が、私はそれを把握することはできません:私は、このコードブロックでエラーメッセージを取得します。

ありがとうございました!あなたがオブジェクトを返さずに、あなたのnon void方法を包んとき

答えて

1

警告Control reaches end of non void functionが来ます。問題を理解するには、マウスを右クリックしてStructureを選択し、Re – Indentを選択します。これで、コードの構造をより簡単に見つけて、何が起きているのかを知ることができます。

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:ペアがファイルで一度に1つずつのメソッドをラップする#endifの

、あなたが投稿1上記の方法で開始する、方法によって、方法をの#ifを移動CellIdentifier警告が再び表示されるまで。それが起こると、あなたは問題の原因を見つけたでしょう。

+0

しかし、新しい要素を追加した後にsearchBarがうまくいかない理由はわかりません... PS:私は客観的に新しい...私は本当にあなたが意味するものを得ることができません... – Daniel05

+0

あなたは見ていますかコード内のコメントのようなコンパイラのエラーが表示されたり、アプリケーションを実行できますか?期待どおりに動作していませんか? – danh

+0

CellIdentifier = NSCFString * \t 0x1b440セル 私は何かを得ることはありません... – Daniel05

関連する問題