ArrayWithObjects: Objects must be NSStrings

I used this code to write strings in my UIPickerView:

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

How can I get NSString instead of "sample"? I tried it with "% @", but it does not work:

self.component1Data = [NSArray arrayWithObjects: @"%@",string, @"%@",string2, @"...", nil];
+3
source share
1 answer
self.component1Data = [NSArray arrayWithObjects: string, string2, nil];

Assuming line and line2 are of type NSString *.

+14
source

Source: https://habr.com/ru/post/1727992/


All Articles