xcode arrayWithObjects:对象应该是 NSStrings
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2038908/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 19:03:43 来源:igfitidea点击:
arrayWithObjects: Objects should be NSStrings
提问by Flocked
I used this code to file the rows in my UIPickerView:
我使用此代码在 UIPickerView 中归档行:
self.component1Data = [NSArray arrayWithObjects: @"Sample", @"Sample1", @"...", nil];
How can I get a NSString instead of the "sample"? I tried it with "%@" but it doesn't work:
如何获得 NSString 而不是“样本”?我用 "%@" 试过了,但它不起作用:
self.component1Data = [NSArray arrayWithObjects: @"%@",string, @"%@",string2, @"...", nil];
回答by bbum
self.component1Data = [NSArray arrayWithObjects: string, string2, nil];
Assuming string and string2 are of type NSString *
.
假设 string 和 string2 的类型为NSString *
。