OC-NSString随意整理,
NSMutableString *str = [NSMutableString stringWithString:@"www-it-heima-com"];
NSMutableString *str1 =[str stringByReplacingOccurrencesOfString:@"-" withString:@"."];
//其实这些string开头的方法都是可以用在不可变字符串中的
//1.拼接格式化(可以字符、整数、实数)
[str1 stringByAppendingFormat:@"%d",10];
//2.拼接一个字符串
[str1 stringByAppendingString:@"123"];
//3.可以说是添加一些字符串,也可以说是覆盖一些
//NSRange range = {a,b};//a是索引位置,b是覆盖多少,b=0,不覆盖,b=1,覆盖1个
NSRange range = {3,0};
[str1 stringByReplacingCharactersInRange:range withString:@"aaa"];
//4.用后面的字符串代替前面的字符串
[str1 stringByReplacingOccurrencesOfString:@"-" withString:@"."];
//5.比较
[str1 compare:str];
BOOL isE =[str isEqualToString:str1];
//6.是否以开头
[str1 hasPrefix:@"w"];
//7.是否以结尾
[str1 hasSuffix:@"n"];
//8.首字母全部大写
[str1 capitalizedString];
//可变的字符串
//1.拼接格式化--(整数、字符)
[str1 appendFormat:@"%d",12];
//2.拼接字符串
[str1 appendString:@"123"];
//3.替换某个位置为字符串
//1.已经知道位置NSRange range = {2,3};
//2.内容太多,找不到位置
// NSRange range = [str1 rangeOfString:@"android"];
[str1 replaceCharactersInRange:range withString:@"asd"];
//4.删除某个位置的字符串
[str1 deleteCharactersInRange:range];
//5.把字符中的索引转为字符
[str1 characterAtIndex:2];
//6.判断是否包含了某字符
BOOL isContain = [str1 containsString:@"w"];
//7.摘取 |--》
[str1 substringFromIndex:3];
[str1 substringToIndex:7];
[str1 substringWithRange:range];
//8.全部大写,全部小写
[str1 uppercaseString];
[str1 lowercaseString];