IOS Foundation框架基本类库的使用 NSMutableString
来源:互联网 发布:淘宝app评价管理在哪 编辑:程序博客网 时间:2024/05/03 08:35
NSMutableString + 方法
//创建一个字符串空串容量为指定capacity大小
+(id)stringWithCapacity:(NSUInteger)capacity;
NSMutableString *str = [NSMutableString stringWithCapacity:10];
//创建一个空的子串(继承自父类的方法)
+(instancetype)string;
NSMutableString *str = [NSMutableString string];
NSMutableString常见的 -方法
//创建一个字符串空串容量为指定capacity大小
- (id)initWithCapacity:(NSUIteger)capacity;
NSMutableString *str = [[NSMutableString alloc] initWithCapacity:10];
//在指定标签位置插入一个字符串对象
- (void)insertString:(NSString *)aString atIndex:(NSUInteger)Ioc;
NSMutableString *str = [NSMutableString stringWithFormat:@"hello world"];
[str insertString:@"beautiful " atIndex:6];
NSLog(@"%@", str);
输出:hello beautiful world;
删除主串中的某一指定范围的字符
- (void)deleteCharactersInRange:(NSRange)range;
NSMutableString *str = [NSMutableString stringWithFormat:@"hello world"];
NSRange range = {2, 3};
[str deleteCharactersInRange:range];
NSLog(@"%@", str);
输出:he world;
//拼接字符串
- (void)appendString:(NSString *)aString;
NSString *str1 = @"world";
NSMutableString *str2 = [NSMutableString stringWithFormat:@"hello "];
[str2 appendString:str1];
NSLog(@"%@", str2);
输出:hello world;
- (void)appendFormat:(NSString *)format,...NS_FORMAT_FUNCTION(1,2);
NSMutableString *str = [NSMutableString stringWithFormat:@"hello "];
[str appendFormat:@"%@", @"world"];
NSLog(@"%@", str);
输出:hello world;
将字符串对象赋值
- (void)setString:(NSString *)aString;
NSMutableString *str = [NSMutableString stringWithFormat:@"hello"];
[str setString:@"world"];
NSLog(@"%@", str);
输出:world;
- IOS Foundation框架基本类库的使用 NSMutableString
- Foundation框架: 7.NSMutableString的基本认识
- IOS Foundation框架基本类库的使用
- IOS Foundation框架基本类库的使用
- Foundation框架--NSMutableString的介绍和使用
- OC中Foundation框架字符串NSString和NSMutableString的使用
- IOS 基础知识 Foundation-NSString和NSMutableString的使用
- IOS 基础知识 Foundation-NSString和NSMutableString的使用
- Foundation框架 - NSString类 、NSMutableString类
- Foundation框架-NSMutableString
- Foundation框架中的NSMutableString
- Foundation框架---NSString 和 NSMutableString
- OC的Foundation框架-字符串(NSString与NSMutableString)
- Foundation框架下的基本类
- Foundation框架下的基本类
- Foundation框架下的基本类
- 【黑马程序员】【Foundation框架】常用类NSString和NSMutableString字符串
- Foundation中的NSMutableString的创建
- cocos2dx喵星人大战
- hdu2502&杭电oj_2502(组合数)
- cin.ignore()函数的用法
- 【嵌入式Linux驱动开发】二、模块
- 快排
- IOS Foundation框架基本类库的使用 NSMutableString
- 理解Android的手势识别
- myeclipse安装svn插件的多种方式
- oracle11g完全卸载and删除注册表
- Linux Socket Programming by Example-第九章 IP与域名
- 这是一个神奇的世界 蓝桥杯预赛成绩有感
- Delphi 中 DevExpress VCL 14.2.6的编译路径设置
- 从一名程序员到销售员的转变
- samba配置详解