views:

230

answers:

1

Hey there,

I have an NSMutableArray of objects. Each object has a property called "Name". I want to join them together in a string with a separator " > ".

So if the name property in each of the objects in my array is "one", "two" and "three" respectively, the result would be "one > two > three".

Thanks, howie

+11  A: 

To get all the name properties, use Key-Value Coding. Then you can just do componentsJoinedByString: to combine them all:

[[objects valueForKey:@"name"] componentsJoinedByString:@" > "]
Chuck
+1 I love using `valueForKey:` on arrays. It's so deliciously useful.
Dave DeLong