kiri kiri - 1 month ago 5
Objective-C Question

How to Split NSArray in to Multi Line Strings

All,

I have a requirement where i have a NSArray arr = @[a,b,c,d]; Now i need to read from the Array and display it the form of multi line, How can we do that

a

b

c

d

Answer

Solution is

NSArray *persons = @[@"A", @"B", @"C",@"D"];
NSString *str = [persons componentsJoinedByString:@"\n"];
NSLog(@"The str sis - %@",str);

The printed result is

The str sis - A
B
C
D
Comments