Dave
Dave

Reputation: 516

xcode - Capitalise Label Output

I'm pretty new to xcode - so please bear with me!

I'm outputting information from a database to UILabels with information like Name, Region, etc (all good, so far). However - there is a column of text in the database which is all in lowercase (ie flat area to the left)...

The lowercase text looks pretty sucky when it's loaded into the app - so without going into the database and changing all 5000 entries, is there a way to force capitalization programmatically (as is possible in CSS, for example)?

For reference, I'm using the following code in the header file:

IBOutlet UILabel *lblfeatures;

Then in the implementation file:

lblfeatures.text = [self.passedDict objectForKey:@"Feature"];

And linked up through the connections inspector.

Thanks so much :)

Upvotes: 0

Views: 123

Answers (2)

iBhavin
iBhavin

Reputation: 1261

you should use this :

lblfeatures.text= [[NSString stringWithFormat:@"(%@)", [self.passedDict objectForKey:@"Feature"]]capitalizedString];

Upvotes: 0

Jernej Strasner
Jernej Strasner

Reputation: 4620

You might want to do something like:

lblfeatures.text = [[self.passedDict objectForKey:@"Feature"] capitalizedString];

There are more methods for capitalization described in https://developer.apple.com/library/Mac/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/Reference/NSString.html#//apple_ref/occ/instm/NSString/capitalizedString.

Upvotes: 3

Related Questions