Search code examples
iphoneiosobjective-cuppercase

How can I capitalize all letters in an NSString?


I'm trying to capitalize all letters in a NSString for a table cell label.

Here's my code:

  // cell title and subtitle
cell.nameLabel.text = listingNode.title;
[cell.nameLabel.text uppercaseString];

It doesn't seem to have any effect at all.


Solution

  • The method uppercaseString returns an uppercased representation of the receiver. Which means you need to collect the returned string and apply that to the label as text.

    Try this,

    NSString *uppercase = [cell.nameLabel.text uppercaseString];
    cell.nameLabel.text =  uppercase;