Had this semantic issue while showing the xml parsed data in the table cell view. application runs successfully but when i select any row then app goes in detail view at that time app crashes. Pls help!!!
Semantic issue occurs in the third case in this line
cell.textLabel.text = aBook.bookID;
App Code:
- (UITableViewCell *)tableView:(UITableView *)tv
cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell =
[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault
reuseIdentifier:CellIdentifier] autorelease];
}
switch (indexPath.section) {
case 0:
cell.textLabel.text = aBook.name;
break;
case 1:
cell.textLabel.text = aBook.author;
break;
case 2:
cell.textLabel.text = aBook.price;
break;
case 3:
cell.textLabel.text = aBook.bookID;
break;
}
return cell;
}
Probably your aBook.bookID variable is a NSInteger, to convert it in a NSString use this:
case 3:
cell.textLabel.text = [NSString stringWithFormat:@"%i", aBook.bookID];
break;
Your case 3 would be depending upon your bookID
For int
cell.textLabel.text = [NSString stringWithFormat:@"%d",aBook.bookID];
For NSInteger
cell.textLabel.text = [NSString stringWithFormat:@"%i",aBook.bookID];
Because You are providing int value to a string
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.