2011-08-19 48 views
0
- (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 

回答

0

stringWithFormat:方法采用带有n参数的字符串格式。根据你的代码示例,你不需要为字符串对象分配内存或者提供某种格式。

相关问题