Objective-C - Concatenating strings separated by pipes
I would like to loop through an array strings and add them to an NSString
in the following way:
NSMutableArray *emailsArray = [[NSMutableArray alloc] initWithObjects:@"One", @"Two", @"Three", nil];
for (id email in emailsArray {
NSString *emails = ??;
}
So the开发者_Go百科 final NSString
should be the following:
NSString *emails = @"One|Two|Three";
Use [emailsArray componentsJoinedByString:@"|"]
for this.
Sample:
NSMutableArray *emailsArray = [[NSMutableArray alloc] initWithObjects:@"One", @"Two", @"Three", nil];
NSString *emails = [emailsArray componentsJoinedByString:@"|"];
Here you'll have emails = @"One|Two|Three"
.
精彩评论