我有一个运行未知次数的 for-in 循环,当它完成运行时,我希望所有名称都像这样附加:name1, name2,name3
等等。
如何在循环中附加字符串?
我在想这样的事情:
if (donePressed)
{
NSString *allFriends;
selectedFriends = friendPicker.selection;
for (NSDictionary * friend in selectedFriends)
{
NSString * friendName = [friend objectForKey:@"name"];
// some built-in method that appends friendName to allFriends with a ", " between them
}
NSLog(@"%@",selectedFriends);
}