How can I convert NSMutableArray
to NSString
bookArray = [[NSMutableArray alloc] init];
[bookArray addObject:@"Book A"];
[bookArray addObject:@"Book B"];
How can I convert NSMutableArray
to NSString
bookArray = [[NSMutableArray alloc] init];
[bookArray addObject:@"Book A"];
[bookArray addObject:@"Book B"];
As per Hot Licks comment you can use below code.
bookArray = [[NSMutableArray alloc] init];
[bookArray addObject:@"Book A"];
[bookArray addObject:@"Book B"];
Then use Below code.
NSString *yourString=[bookArray description];
if you want to use NSMutableString
and Some different separator then use Below Code.
NSMutableString* content = [NSMutableString string];
for (int aa=0; aa < [bookArray count]; aa++){
[content appendString:[NSString stringWithFormat:@"%@<separator>",[bookArray objectAtIndex:aa]]];
}
Its very simple :
NSString *string=[bookArray componentsJoinedByString:@", "]; //your separator anything