You can do it like this:
self.artistLabel.text = [NSString
stringWithFormat:@"%@ %@"
, self.string1
, self.string2
];
Question
I have a label that needs to display two strings. At the moment I have this:
self.artistLabel.text = self.string1;
I want to be able to display string 1 and string 2. if possible, I also need to have an "@" symbol in between the two strings. I know it must be simple, I just can't figure it out.
Solution
You can do it like this:
self.artistLabel.text = [NSString
stringWithFormat:@"%@ %@"
, self.string1
, self.string2
];
OTHER TIPS
//Create a new string from both string1 and string2 with an "@" in the middle
NSString *artistLabelString = [NSString stringWithFormat:"%@@@%@", self.string1, self.string2];
//Set the label
self.artistLabel.text = artistLabelString;
Just as a BTW, the @@
in the middle gives you a single @
.
You can display only one string in one UILabel. However, that string can itself be a combination of multiple strings.
To combine strings, look into methods like stringByAppendingString:
.