使用componentsJoinedByString:方法打印数组

时间:2011-07-15 17:26:56

标签: xcode uitableview nsstring xcode4

嘿伙计们我正在使用上面的方法:

string = [array componentsJoinedByString:@"\n"];

这会打印出我的数组中的每个obj,但打印出来的是:

{
Selected = 0;
name = "boots";
number = 69;
}
{
Selected = 0;
name = house;
number = 1001;
}
}
Selected = 0;
name = shirt;
number = 1234;
}
{
Selected = 0;
name = Brewski;
number = 4567;
}



 and i just want it to print out:

 Brewski
 Boots...

etc.. 

1 个答案:

答案 0 :(得分:5)

数组中的对象似乎是字典。你应该这样做。

[[array valueForKey:@"name"] componentsJoinedByString:@"\n"]