NSArray *array1 = [NSArray arrayWithObjects:@"1", @"2", @"3", nil];
NSString *joinedString = [array1 componentsJoinedByString:@","];
componentsJoinedByString:
will join the components in the array by the specified string and return a string representation of the array.
The method you are looking for is componentsJoinedByString
.
NSArray *a = [NSArray arrayWithObjects:@"1", @"2", @"3", nil];//returns a pointer to NSArray
NSString *b = [a componentsJoinedByString:@","];//returns a pointer to NSString
NSLog(@"%@", b); // Will output 1,2,3
NSArray
class reference:
NSArray *pathArray = [NSArray arrayWithObjects:@"here",
@"be", @"dragons", nil];
NSLog(@"%@",
[pathArray componentsJoinedByString:@" "]);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With