I have a NSArray
of Foo
objects.
我有一个Foo对象的NSArray。
@interface Foo : NSObject
{
}
- (NSString *) name;
@end
I want to be able to join all these [Foo name]
results into one NSString
.
我希望能够将所有这些[Foo name]结果合并到一个NSString中。
In C# I would get a array of these by using LINQ, creating a Array of it, and feeding it to String.Join()
:
在c#中,我将通过使用LINQ获得这些元素的数组,创建它们的数组,并将其输入String.Join():
List<Foo> foo = [..];
String.Join(",", foo.select(F => F.name()).ToArray());
Is something like this possible in Objective-C?
这在Objective-C中可能吗?
I know about [NSArray componentsJoinedByString]
, but how would I just easily select the [Foo name]
properties of all the objects without manually looping trough its contents?
我知道[NSArray componentsJoinedByString],但我如何能够轻松地选择所有对象的[Foo name]属性,而不通过其内容进行手动循环?