我想在NSMutableArray的对象中添加一个预定义的字符串。我以为你会使用%@
,但显然下面的代码执行得不好。提前谢谢
arrayData = [[NSMutableArray alloc]
initWithObjects:@"%@ you look tired." name,
@"Why do you smell so bad?",
@"I have to go potty!",
@"%@ put your pants on!" name,
@"Mommy!",
@"Daddy!",
@"NOOOOOO!",
@"When are we going to get there?",
@"I HATE YOU!",
nil];
答案 0 :(得分:5)
%@
在stringWithFormat:
电话中有效。您的代码应如下所示:
arrayData = [[NSMutableArray alloc] initWithObjects:
[NSString stringWithFormat:@"%@ you look tired.", name],
@"Why do you smell so bad?",
@"I have to go potty!",
[NSString stringWithFormat:@"%@ put your pants on!", name],
@"Mommy!",
@"Daddy!",
@"NOOOOOO!",
@"When are we going to get there?",
@"I HATE YOU!",
nil];