iphone 的NSString NSMutableString的用法
2011-07-27 10:45
483 查看
1、初始化字符串一
2、初始化字符串二
3、字符串的替换注:将字符串中的参数进行替换参数1:目标替换值参数2:替换成为的值参数3:类型为默认:NSLiteralSearch参数4:替换的范围
4、给字符串分配容量
5、追加字符串
6、在已有字符串中按照所给出范围和长度删除字符
7、在已有字符串后面在所指定的位置中插入给出的字符串
8、按照所给出的范围,和字符串替换的原有的字符
9、判断字符串内是否还包含别的字符串(前缀,后缀)
10、返回一个数组,包含从已经由一个给定的分隔符分为接收器串。- (NSArray*)componentsSeparatedByString:(NSString*)NString参数
分离器
分隔符的字符串。
11、是否包含该字符串
[[NSString alloc] initWithFormat:@"%d",10]; |
[[NSString alloc] initWithCString:@"字符串内容"] |
[str replaceOccurrencesOfString:@"1" withString:@"222" options:NSLiteralSearch range:NSMakeRange(0, [str length])]; |
NSMutableString *String; String = [NSMutableString stringWithCapacity:40]; |
NSMutableString *String1 = [[NSMutableString alloc] initWithString:@"This is a NSMutableString"]; [String1 appendFormat:[NSString stringWithFormat:@", I will be adding some character"]]; |
NSMutableString *String1 = [[NSMutableString alloc] initWithString:@"This is a NSMutableString"]; [String1 deleteCharactersInRange:NSMakeRange(0, 5)]; |
NSMutableString *String1 = [[NSMutableString alloc] initWithString:@"This is a NSMutableString"]; [String1 insertString:@"Hi! " atIndex:0]; |
NSMutableString *String1 = [[NSMutableString alloc] initWithString:@"This is a NSMutableString"]; [String1 replaceCharactersInRange:NSMakeRange(0, 4) withString:@"That"]; |
NSString *String1 = @"NSStringInformation.txt"; [String1 hasPrefix:@"NSString"] = = 1 ? NSLog(@"YES") : NSLog(@"NO"); [String1 hasSuffix:@".txt"] = = 1 ? NSLog(@"YES") : NSLog(@"NO"); |
分离器
分隔符的字符串。
NSString *list = @"Norman, Stanley, Fletcher"; NSArray *listItems = [list componentsSeparatedByString:@", "]; listItems包含了:{ @"Norman", @"Stanley", @"Fletcher" }. |
NSRange range = [@"字符串--A" rangeOfString:“是否包含--B”]; if (range.location == NSNotFound){//不包含}else{//包含} |
相关文章推荐
- iphone 的NSString NSMutableString的用法
- iphone NSString与NSMutableString的区别
- iphone NSString与NSMutableString的区别
- NSString、NSMutableString基本用法
- NSString+NSMutableString+NSValue+NSAraay用法汇总
- NSString+NSMutableString+NSValue+NSAraay用法汇总
- NSString+NSMutableString+NSValue+NSAraay用法汇总(很不错的哦)
- NSString+NSMutableString+NSValue+NSAraay用法汇总1
- 黑马程序员---OC学习笔记之NSString的其他使用和NSMutableString的用法
- NSString+NSMutableString+NSValue+NSAraay用法汇总
- NSString、NSMutableString基本用法
- NSString+NSMutableString+NSValue+NSAraay用法汇总(很不错的哦)
- NSString+NSMutableString+NSArray+NSMutableArray+NSNumber+NSValue用法汇总
- NSString+NSMutableString+NSValue+NSAraay用法汇总3
- NSString+NSMutableString+NSValue+NSAraay用法汇总
- NSString+NSMutableString+NSValue+NSAraay用法汇总
- NSString和NSMutableString的基本用法
- NSString+NSMutableString+NSValue+NSAraay用法汇总4 nsarrary
- NSString 和 NSMutableString 定义和基本用法
- NSString+NSMutableString+NSValue+NSAraay用法汇总5