I have a NSArray
of Foo
objects.
@interface Foo : NSObject
{
}
- (NSString *) name;
@end
I want to be able to join all these [Foo name]
results into one NSString
.
In C# I would get a array of these by using LINQ, creating a Array of it, and feeding it to String.Join()
:
List<Foo> foo = [..];
String.Join(",", foo.select(F => F.name()).ToArray());
Is something like this possible in 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?
[[myArray valueForKey:@"name"] componentsJoinedByString:@","]
(docs)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With