arrayWithObjects:对象应该是NSStrings

时间:2010-01-10 22:28:50

标签: iphone objective-c xcode

我使用此代码在UIPickerView中提交行:

self.component1Data = [NSArray arrayWithObjects: @"Sample", @"Sample1", @"...", nil];

如何获取NSString而不是“样本”?我用“%@”尝试了它,但它不起作用:

self.component1Data = [NSArray arrayWithObjects: @"%@",string, @"%@",string2, @"...", nil];

1 个答案:

答案 0 :(得分:14)

self.component1Data = [NSArray arrayWithObjects: string, string2, nil];

假设string和string2的类型为NSString *