NSString as usual summary (a) supplement
. 1 NSString * STR = [NSString stringWithFormat: @ " the I Love Programing by You, Come here Wallpaper! " ]; 2 // case String object into 3 // converted to uppercase . 4 NSString upStr * = [STR uppercaseString]; . 5 NSLog ( @ " STR =% @ " , STR); . 6 NSLog ( @ " upStr =% @ " , upStr); . 7 // lowercase . 8 NSString lowerStr * = [STR lowercaseString]; . 9 NSLog ( @ " lowerStr% = @ " , lowerStr); 10 // converted initials . 11 NSString newStr * = [STR capitalizedString]; 12 is NSLog ( @ " newStr =% @ " , newStr); 13 is 14 // string extraction 15 // specified position to the end: 16 NSString * = substr [STR substringFromIndex: . 7 ]; . 17 NSLog ( @ " substr =% @ " , substr); 18 is // extract a specified length (by NSRange) from the specified location . 19 substr = [STR substringWithRange: NSMakeRange ( . 7 , . 7 )] ; 20 NSLog ( @ " substr =% @ " , substr); 21 is // beginning to the specified position 22 is substr = [STR substringToIndex: . 6 ]; 23 is NSLog ( @ " substr =% @ " , substr); 24 25 // string cutting (componentsSeparatedByString :) method 26 // this method of dividing a character string transmitted, and divides the result returned to the array 27 NSArray strArr * = [STR componentsSeparatedByString: @ " " ]; 28 for ( ID STR in strArr) { 29 NSLog ( @ "@% " , STR); 30 } 31 is // splicing to give the string array (string specified) 32 NSString myStr * = [strArr componentsJoinedByString: @" __ " ]; 33 is NSLog ( @" myStr =% @ " , myStr); 34 is // the set passed in NSCharacterSet divided (example contains a comma "," and space "") 35 strArr = [STR componentsSeparatedByCharactersInSet: [NSCharacterSet characterSetWithCharactersInString: @ " , " ]]; 36 for ( ID STR in strArr) { 37 [ NSLog(@"%@", str); 38 }
Reproduced in: https: //www.cnblogs.com/pretty-guy/p/3975088.html