2011-01-25 17 views
0

スクロール時にUITableViewがクラッシュするここに...なぜ私はそれがクラッシュしたスクロールしようとする場合、私は今の合計数= 22スクロール時にUITableViewがクラッシュする

Row Number 0 
Row NUmber 1 
. 
. 
Row Number 21 (This row number will pull the last object from ObjectArray) 

を見ることができますコンソールで

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { 

NSLog(@"Total Count: %d",count); 
return [ObjectArray count] ; 
} 


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

static NSString *CellIdentifier = @"Cell"; 


    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 




    if (cell == nil) { 

    cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease]; 

    cell.textLabel.numberOfLines = 0; 
    cell.textLabel.font = [UIFont fontWithName:@"Arial" size:12.0]; 
    cell.detailTextLabel.font = [UIFont fontWithName:@"Arial" size:10.0]; 

    [cell.textLabel sizeToFit]; 
    [cell setAccessoryType:UITableViewCellAccessoryDetailDisclosureButton]; 


    } 

// Configure the cell. 

NSLog(@"Row Number %d", indexPath.row); 
cell.textLabel.text = [ObjectArray name]; 
return cell; 
} 

...サンプルコードですか?誰もが...これで

+1

コードを正しく再フォーマットし、クラッシュのスタックトレースを投稿してください。 –

+0

ObjectArrayの詳細についても触れてください。現時点ではObjectArrayはArrayではないように使用されています。すなわち、 [ObjectArray name] ... 'array'からオブジェクトを取得しない – martinws

+0

スタックトレースが必要です。 –

答えて

0

を私を助けることができる私は本当にコード

  cell.textLabel.text = [ObjectArray name]; 

のこの行を理解していないObjectArrayはNSArrayのインスタンスである場合、それはそのセレクタに応答しないでしょう。とにかくおそらくスムースを返すようにしたいと思います

  cell.textLabel.text = [ObjectArray objectAtIndex: [indexPath row]]; 
+0

私の悪い...私はあなたを混乱させるように実際のコードを修正しようとしました。 ObjectArrayはNSMutableArrayです。 ObjectArrayにオブジェクト型 "MyObject"が設定されていると確信しています。 MyObjectには、 "name"と "age"という名前のインスタンス変数があります。 NSLog(@ "行番号%d"、indexPath.row)の変更されたコードはここにあります。 cell.textLabel.text = [ObjectArray name]; MyObject * temp = [ObjectArray objectAtIndex:indexPath.row] cell.textLabel.text = [一時的な名前]; [暫定リリース] 私の開発マシンが稼動中です。メモ帳でこれを書いてください。構文エラーは無視してください。 – bp581

+0

[temp release] - それを解放しているので、テーブルビューが2回目にそのアイテムにアクセスしようとしているときに、すでに解放されています。その行を削除してください – Max

+0

理由は、temp.name変数は保持されていて、temp自身ではありません。 – Max

関連する問題