警告:格式不是字符串文字,也没有格式参数。有什么想法吗?
- (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
- (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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
stringWithFormat:
方法采用带有n
参数的字符串格式。根据您的需要,只需使用:根据您的代码示例,您不需要为字符串对象分配内存或提供某种格式。
The
stringWithFormat:
method takes a string format withn
arguments. For your needs, just use:According to your code example, you don't need to allocate memory for the string object or provide a certain format.