I am new in iOS and i am not able to find solution of my question . So please tell me how can i concatenate all values of array in iOS
Asked
Active
Viewed 2,115 times
0
-
1I think you search like this solution. But before posting any question you have to search properly on google. Here is your solution given by me: [Solution](http://stackoverflow.com/a/14438617/1450762) – Ajay Chaudhary May 17 '13 at 10:42
-
If you found the solution of your Problem then You should "Mark answer Accepted". – Bhavin May 18 '13 at 07:30
3 Answers
2
Answer : -componentsJoinedByString: .
It will join the components in the array by the specified string and return a string representation of the array.
Use : NSString *finalStr = [yourArray componentsJoinedByString:@" "];
GoodLuck !!!
1
if you are using string values in NSArray then it is quite simple. You can just run for loop and use a NSMutableString to append the data.
NSArray *_array;//Your Initialized Array
NSMutableString *_string =[[NSMutableString alloc]init];
for(int i= 0 ;i<[_array count];i++)
{
[_string appendFormat:@"%@",[_array objectAtIndex:i]];
}
NSLog(@"_string = %@",_string);

Sugan S
- 1,782
- 7
- 25
- 47

Deepak Srivastava
- 178
- 7
0
NSMutableString* theString = [NSMutableString string];
for (int i=0; i<[array count];i++){
[theString appendString:[NSString stringWithFormat:@"%i ",i]];
}
NSLog(@"mystirng=%@", theString;);

SAMIR RATHOD
- 3,512
- 1
- 20
- 45