问题描述:

- (void)tableView:(UITableView *)tableView

didSelectRowAtIndexPath:(NSIndexPath *)indexPath {

NSArray *listData =[self.tableContents objectForKey:

[self.sortedKeys objectAtIndex:[indexPath section]]];

NSUInteger row = [indexPath row];

NSString *rowValue = [listData objectAtIndex:row];

NSString *message = [[NSString alloc] initWithFormat:rowValue];

UIAlertView *alert = [[UIAlertView alloc]

initWithTitle:@"You Better Be There Or Be Watching It!"

message:message delegate:nil

cancelButtonTitle:@"Go Knights!"

otherButtonTitles:nil];

[alert show];

[alert release];

[message release];

[tableView deselectRowAtIndexPath:indexPath animated:YES];

}

Line of code that throws error:

NSString *message = [[NSString alloc] initWithFormat:rowValue];

----------

Warning Message: format not a string literal and no format arguments

网友答案:

The stringWithFormat: method takes a string format with n arguments. For your needs, just use:

NSString *message = rowValue;

According to your code example, you don't need to allocate memory for the string object or provide a certain format.

相关阅读:
Top