Orp*_*ury 3 iphone cocoa-touch objective-c nsarray
我正在使用以下代码片段来处理我正在努力打印iPhone屏幕上的单词列表的应用程序:
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
Run Code Online (Sandbox Code Playgroud)
列出的单词显示在标签中的多行上,但是数组由括号括起并用逗号分隔.
例如,如果我有一个NSDictionary键@"Cat",它有一个NSArray值,如下所示:@"snow leopard",@"lion",@"tiger",那么我在屏幕上的输出将如下:
(
snow leopard,
lion,
tiger
)
Run Code Online (Sandbox Code Playgroud)
有没有办法摆脱这个标点符号?
谢谢!
这不是description方法的目的,隐含地被调用来形成该字符串.您应该使用以下内容:
[[self.dictionary selectList] componentsJoinedByString:@" "];
Run Code Online (Sandbox Code Playgroud)
这将采用一个数组并将其与每个项目之间的空格连接起来.
| 归档时间: |
|
| 查看次数: |
923 次 |
| 最近记录: |