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

前端 未结 2 909
隐瞒了意图╮
隐瞒了意图╮ 2020-12-01 18:25

I found the function below :

CFStringCapitalize

\"Changes the first character in each word of a string to uppercase (if it is a low

相关标签:
2条回答
  • 2020-12-01 18:51

    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.

    0 讨论(0)
  • 2020-12-01 19:04
    (NSString *)capitalizedString
    

    So:

    NSString *myString,*myCapitalizedString;
    
    myString = @"capitalize";
    myCapitalizedString = [myString capitalizedString]; //produces a capitalized copy of 'myString'
    
    0 讨论(0)
提交回复
热议问题