I am using the following code snippet for an app I’m working on to print a list of words on the iPhone screen:
NSString *labelText = [[NSString alloc] initWithFormat:@"%@", [self.dictionary selectList]];
//creates a string list from an NSDictionary key with a value of an NSArray that has NSString objects in it
self.listLabel.text = labelText;
//displays list in label
The listed words are displayed on multiple lines in a label, but the array is bookended by parentheses and is separated by commas.
For example, if i have an NSDictionary key @”Cat” which has an NSArray value added to it like so: @”snow leopard”, @”lion”, @”tiger”, then my output on screen will be the following:
(
snow leopard,
lion,
tiger
)
Is there a way to get rid of this punctuation?
Thank you!
That’s not really the purpose of the
descriptionmethod, what’s implicitly being called to form that string. You should use the following:Which will take an array and join it with spaces between each item.