Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
514 views
in Technique[技术] by (71.8m points)

iphone - Change the first character in each word of a string to uppercase

I found the function below :

CFStringCapitalize

"Changes the first character in each word of a string to uppercase (if it is a lowercase alphabetical character)."

void CFStringCapitalize (
   CFMutableStringRef theString,
   CFLocaleRef locale
);

Does anyone know how to use it with my NSMutableString ?

Thank you,

Gauthier.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

The capitalizedString method exists in NSString class, see the docs

NSString *foo = @"this is all lower";
NSString *fooUpper = [foo capitalizedString];

Note that this isn't iPhone specific, same code on the Mac.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...