开发者

Is there any "Built in function to Concatenate the whole NSMutableArray NSString items"?

开发者 https://www.devze.com 2023-04-11 17:58 出处:网络
is开发者_开发问答 there any built in function to Concatenate the whole NSMutableArray NSString items

is开发者_开发问答 there any built in function to Concatenate the whole NSMutableArray NSString items

i have an NSMutableArray with 4 elements in the following structure

myArray[0] = "HI";
myArray[1] = "WELCOME";
myArray[2] = "TO";
myArray[3] = "STACKOVERFLOW";

I need to get the sentence "HI WELCOME TO STACKOVERFLOW" from my NSMutableArray(myArray) .

may i know , any built in functions to do it?

Thanks

NB:Without iterating the array through any loop


Yes, there's function you need:

 NSString *result = [myArray componentsJoinedByString:@" "];


Yes:

[NSArray componentsJoinedByString:@" "]


Simply do NSString *myString = [myArray componentsJoinedByString:@" "];

0

精彩评论

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

关注公众号