1

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

1 Answer 1

13

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

[[objects valueForKey:@"name"] componentsJoinedByString:@" > "]
Sign up to request clarification or add additional context in comments.

1 Comment

+1 I love using valueForKey: on arrays. It's so deliciously useful.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.