开发者

Joining all the elements in an NSMutableArray to form an NSString

开发者 https://www.devze.com 2023-02-03 10:05 出处:网络
I have an NSMutableArray of NSString objects. How would I make an NSString that consists of all the elements in that array joined together with semicolons in between?

I have an NSMutableArray of NSString objects. How would I make an NSString that consists of all the elements in that array joined together with semicolons in between?

For example:

array = "hello","hi","bye",nil;
output = "hello开发者_StackOverflow中文版;hi;bye";


NSMutableArray *array = [NSMutableArray arrayWithObjects:@"hello", @"hi", @"bye", nil];
NSString *output = [array componentsJoinedByString:@";"];
0

精彩评论

暂无评论...
验证码 换一张
取 消