2012-01-05 7 views
0

私はUITableViewを作成していますが、すべてのことがコードでうまくいってビルドが成功しましたが、シミュレータで実行したときに成功しました。UITableViewのエラー

スレッド1:プログラム受信信号: "EXC_BAD_ACCESS"。

ごrefernceについては、以下の私のコードを見つける:エラーがこの行にある

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ 
    UITableViewCell *cell =[tableView dequeueReusableCellWithIdentifier:@"Mycell"]; 
    if(cell == nil){ 
     cell =[[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"MYcell"]autorelease]; 
    } 
    cell.textLabel.text=[NSString stringWithFormat:@"cell %@",(unsigned long)indexPath.row+1]; 

    return cell; 
} 

cell.textLabel.text=[NSString stringWithFormat:@"cell %@",(unsigned long)indexPath.row+1]; 

は親切にあなたの提案

答えて

2

を投稿あなたは間違った書式指定子を使用しています。 %@を整数の%dを使用して、オブジェクトに対して次のとおりです。

cell.textLabel.text=[NSString stringWithFormat:@"cell %d",(unsigned long)indexPath.row+1]; 
+0

cell.textLabel.text=[NSString stringWithFormat:@"cell %d",(unsigned long)indexPath.row+1]; 

それが働いている – user1118664

0

利用代わり

cell.textLabel.text=[NSString stringWithFormat:@"cell %@",(unsigned long)indexPath.row+1]; 
+0

ありがとうを働いているあなたに感謝 – user1118664