Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I capitalize all letters in an NSString? [duplicate]

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.

like image 289
user2588945 Avatar asked Sep 02 '13 10:09

user2588945


3 Answers

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; 
like image 126
Amar Avatar answered Oct 25 '22 15:10

Amar


NSString * str=@"jit";

NSLog(@"%@",[str uppercaseString]);


cell.nameLabel.text=[str uppercaseString];
like image 37
Jitendra Avatar answered Oct 25 '22 17:10

Jitendra


You need to just convert your string to uppercase

cell.nameLabel.text=[String_name uppercaseString];
like image 30
Agent Chocks. Avatar answered Oct 25 '22 15:10

Agent Chocks.