3、字符串的替换
注:将字符串中的参数进行替换
参数1:目标替换值
参数2:替换成为的值
参数3:类型为默认:NSLiteralSearch
参数4:替换的范围
[str replaceOccurrencesOfString:@"1" withString:@"222" options:NSLiteralSearch range:NSMakeRange(0, [str length])];
5、追加字符串
NSMutableString *String1 = [[NSMutableString alloc] initWithString:@"This is a NSMutableString"];
[String1 appendFormat:[NSString stringWithFormat:@", I will be adding some character"]];[String1 hasSuffix:@".txt"] = = 1 ? NSLog(@"YES") : NSLog(@"NO");
10、返回一个数组,包含从已经由一个给定的分隔符分为接收器串。
- (NSArray*)componentsSeparatedByString:(NSString*)NString
参数
分离器
分隔符的字符串。
NSString *list = @"Norman, Stanley, Fletcher";
NSArray *listItems =
[list componentsSeparatedByString:@", "];
listItems包含了:
{ @"Norman", @"Stanley", @"Fletcher" }.
11、是否包含该字符串
NSRange range = [@"字符串--A" rangeOfString:“是否包含--B”];
if (range.location == NSNotFound)
{//不包含
}
else
{//包含
}