开发者

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

开发者 https://www.devze.com 2022-12-21 22:14 出处:网络
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).\"

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,

Gau开发者_StackOverflow中文版thier.


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.


(NSString *)capitalizedString

So:

NSString *myString,*myCapitalizedString;

myString = @"capitalize";
myCapitalizedString = [myString capitalizedString]; //produces a capitalized copy of 'myString'
0

精彩评论

暂无评论...
验证码 换一张
取 消