标题: Foundation框架之可变字符串 [打印本页] 作者: mac 时间: 2015-9-23 10:11 标题: Foundation框架之可变字符串 //
// main.m
// FoundationFramework
//
// Created by Kenshin Cui on 14-2-16.
// Copyright (c) 2014年 Kenshin Cui. All rights reserved.
//
//插入字符串
[str1 insertString:@"My name is Kenshin." atIndex:12];
NSLog(@"%@",str1);
//结果:hello,world!My name is Kenshin.我的年龄是18。Honey,I love you.
//删除指定字符串
[str1 deleteCharactersInRange:[str1 rangeOfString:@"My name is Kenshin."]];//删除指定范围的字符串
NSLog(@"%@",str1);
//结果:hello,world!我的年龄是18。Honey,I love you.