Reputation: 45
I am creating an UITableView, every thing goes fine in code and build got succeeded, but when I run in simulator. it is showing a error as:
Thread 1: Program received signal :"EXC_BAD_ACCESS".
find my code below for your 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;
}
The error is on this line:
cell.textLabel.text=[NSString stringWithFormat:@"cell %@",(unsigned long)indexPath.row+1];
kindly post your suggestion
Upvotes: 0
Views: 93
Reputation: 3416
Use
cell.textLabel.text=[NSString stringWithFormat:@"cell %d",(unsigned long)indexPath.row+1];
instead of
cell.textLabel.text=[NSString stringWithFormat:@"cell %@",(unsigned long)indexPath.row+1];
Upvotes: 0
Reputation: 119292
You are using the wrong format specifier. %@ is for objects, use %d for integers:
cell.textLabel.text=[NSString stringWithFormat:@"cell %d",(unsigned long)indexPath.row+1];
Upvotes: 2