OC 自带方法 简绍 2 NSMutableString
来源:互联网 发布:公安网络布控 编辑:程序博客网 时间:2024/05/16 04:12
1. NSMutableString // 可以改变的string
+ (NSMutableString *)stringWithCapacity:(NSUInteger)capacity //
NSMutableString * string = [NSMutableString stringWithFormat:@"蓝鸥"];
2.appendString // 给可变字符添加字符串
- (void)appendString:(NSString *)aString // Adds to the end of the receiver the characters of a given string.
例子:
[string appendString:@"科技"];
NSLog(@"%@", string);
3.deleteCharactersInRange 给一个范围 删除字符串
- (void)deleteCharactersInRange:(NSRange)aRange // Removes from the receiver the characters in a given range.
例子:
[string deleteCharactersInRange:NSMakeRange(1, 2)];
NSLog(@"%@", string);
4.insertString 给一个起点 插入字符串
func insertString(_ aString: String,
atIndex anIndex: Int)
//Inserts into the receiver the characters of a given string at a given location.
例子:
[string insertString:@"鸥科" atIndex:1];
NSLog(@"%@", string);
5.replaceCharactersInRange: // 给一个范围用 给定的字符串替换
- (void)replaceCharactersInRange:(NSRange)aRange
withRTF:(NSData *)rtfData
//Replaces the characters in the given range with RTF text interpreted from the given RTF data.
[string replaceCharactersInRange:NSMakeRange(1, 1) withString:@"鸟"];
NSLog(@"%@", string);
6.setString 把内容重置
- (void)setString:(NSString *)aString // Replaces the characters of the receiver with those in a given string.
[string setString:@""];
NSLog(@" string = %@", string);
7. compare 比较两个字符串大小, 返回一个枚举型 NSComparisonResult
- (NSComparisonResult)compare:(id)otherCell //Compares the string values of the receiver another cell, disregarding case.
NSString * str1 = @"abc";
NSString * str2 = @"aac";
NSComparisonResult result = [str1 compare:str2];
NSLog(@"%ld", result);
- OC 自带方法 简绍 2 NSMutableString
- OC 自带方法 简绍 1 NSString
- OC 自带方法 简绍 3 NSArray
- OC 自带方法 简绍 4 NSMutableArray
- OC 自带方法 简绍 5 NSDictionary
- OC 自带方法 简绍 6 NSSet
- OC 自带排序方法
- 06-OC中NSMutableString常见方法
- NSJSON的用法(oc系统自带的解析方法)
- 【Objective-C】OC中可变字符串(NSMutableString)常用方法
- [OC学习笔记]常见的NSString、NSMutableString方法
- iOS开发-Day17-OC NSString / NSMutableString常用方法
- OC关于NSString和NSMutableString方法的使用
- OC中字符串的方法使用(NSString、NSMutableString、NSRange)
- OC-038.可变字符串NSMutableString创建和方法
- OC中字符串类(NSString和NSMutableString)常用方法汇总
- NSMutableString-OC+class
- OC - NSString/NSMutablestring
- nginx配置rtmp流媒体服务器
- vs.php中使用apache或IIS7进行外部调试
- Longest Consecutive Sequence 递归实现
- 关于spring下载源码的一点吐槽
- ARM Program Status Register 和 相关指令之笔记
- OC 自带方法 简绍 2 NSMutableString
- Objective - C基础: 第二天 - 6.关键字self的基本认识
- 总结:One weird trick for parallelizing convolutional neural networks
- 求数据类型所占字节和取值范围
- Android 应用的兼容性
- 【NumPy基础】100道numpy练习——Apprentice篇
- java--String 类用法
- 真正完美解决vs2008 添加启动画面(基于对话框)
- 对递归的新认识