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:@" "];
精彩评论