Amendale
Amendale

Reputation: 317

Objective c - insert character into string between certain characters

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.

Upvotes: 0

Views: 274

Answers (1)

rdelmar
rdelmar

Reputation: 104082

How about,

NSString *newString = [array componentsJoinedByString:@"*"];

Upvotes: 2

Related Questions