0

I need to insert a character into a string between each occurrence of strings that I have in an array. For example:

array = [ab,bc,cd,de];
string = @"abbccd";

newString = @"ab*bc*cd";

How can I accomplish this? I looked around but couldn't find a good solution. Thanks.

1
  • What if the string contains substrings that aren't in the array? Commented Apr 21, 2013 at 22:19

1 Answer 1

2

How about,

NSString *newString = [array componentsJoinedByString:@"*"];
Sign up to request clarification or add additional context in comments.

Comments

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.