IOS changes the case sensitivity of letters.

Source: Internet
Author: User

IOS changes the case sensitivity of letters.

Use lowercaseString and uppercaseString

- (void)test{    NSString *testString = @"Hello World";        // lower case    NSString *lowerCaseString1 = [testString lowercaseString];    NSString *lowerCaseString2 = testString.lowercaseString;        // upper case    NSString *upperCaseString1 = [lowerCaseString1 uppercaseString];    NSString *upperCaseString2 = lowerCaseString1.uppercaseString;        NSLog(@"lowerCaseString1: %@",lowerCaseString1);    NSLog(@"lowerCaseString2: %@",lowerCaseString2);    NSLog(@"upperCaseString1: %@",upperCaseString1);    NSLog(@"upperCaseString2: %@",upperCaseString2);        // capitalize the first word of the sentence    NSString *txt = @"hi my friends!";    txt = [txt stringByReplacingCharactersInRange:NSMakeRange(0,1) withString:[[txt substringToIndex:1] uppercaseString]];    NSLog(@"txt: %@", txt);}

Print result:

2014-08-26 17:00:30.266 MyApp[68821:60b] lowerCaseString1: hello world2014-08-26 17:00:30.267 MyApp[68821:60b] lowerCaseString2: hello world2014-08-26 17:00:30.267 MyApp[68821:60b] upperCaseString1: HELLO WORLD2014-08-26 17:00:30.267 MyApp[68821:60b] upperCaseString2: HELLO WORLD2014-08-26 17:00:30.268 MyApp[68821:60b] txt: Hi my friends!

Reference Source:

Http://stackoverflow.com/questions/8693741/converting-all-text-to-lower-case-in-objective-c

Http://stackoverflow.com/questions/2432452/how-to-capitalize-the-first-word-of-the-sentence-in-objective-c

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.