How to insert a character into a NSString
How do I insert a space to a NSString.
I need to add a space at index 5 into:
NString * dir = @"abcdefghijklmno";
To get this result:
abcde fghijklmno
with:
NSLOG (@"%@", dir);
You need to use NSMutableString
NSMutableString *mu = [NSMutableString stringWithString:dir];
[mu insertString:@" " atIndex:];
or you could use those method to split your string :
– substringFromIndex:
– substringWithRange:
– substringToIndex:
and recombine them after with
– stringByAppendingFormat:
– stringByAppendingString:
– stringByPaddingToLength:withString:startingAtIndex:
http://stackoverflow.com/questions/8722051/how-to-insert-a-character-into-a-nsstring
How to insert a character into a NSString的更多相关文章
- NSString、NSMutableString基本用法
NSString其实是一个对象类型.NSString是NSObject(Cocoa Foundation的基础对象)的子类 一.NSString的创建 1.创建常量字符串.NSString *astr ...
- NSString的常见方法
//1.创建常量字符串. NSString *astring = @"This is a String!"; //2.创建空字符串,给予赋值. NSString *astrin ...
- iOS NSString的常用用法
//1.创建常量字符串. NSString *astring = @"This is a String!"; //2.创建空字符串,给予赋值. NSString *astrin ...
- NSString 截取字符串
NSString字符串常用方法2010-09-06 14:18/******************************************************************** ...
- NSString、NSMutableString基本使用
郝萌主倾心贡献.尊重作者的劳动成果,请勿转载. 假设文章对您有所帮助.欢迎给作者捐赠,支持郝萌主.捐赠数额任意.重在心意^_^ 我要捐赠: 点击捐赠 Cocos2d-X源代码下载:点我传送 游戏官方下 ...
- NSString 练习
//将“⽂文艺⻘青年”改成“213⻘青年”. NSString *str = @"文艺青年"; NSString *str1 = [str stringByRepl ...
- NSString 字符串操作
//一.NSString /*----------------创建字符串的方法----------------*/ //1.创建常量字符串. NSString *astring = @"Th ...
- NSString 用法大全。
一.NSString 创建字符串. NSString *astring = @"This is a String!"; 创建空字符串,给予赋值. NSString *astri ...
- 转:用法总结:NSNumber、NSString、NSDate、NSCalendarDate、NSData(待续)
NSNumber + (NSNumber *)numberWithInt:(int)value; + (NSNumber *)numberWithDouble:(double)value; - (in ...
随机推荐
- 阿里 Java面试 知识点
摘自: http://blog.csdn.net/wtyvhreal/article/details/45291835 =================================== 基础知识 ...
- hbase删除region块的脚本
删除hbase表region块脚本 文件hua.txt格式: CHAT_INFO,1318153079100530000314050,1318173760068.991ca04ff164c3f7987 ...
- linux修改登陆后进入的默认目录
如将root登陆后进入的路径由/root改为/opt/FriendlyARM/linux/u-boot-mini6410修改/etc/pssswd 修改行 root:x:0:0:root:/root: ...
- ASP.NET中Server对象的几个方法
HtmlDecode 已重载. 对已被编码以消除无效 HTML 字符的字符串进行解码.HtmlEncode 已重载. 对要在浏览器中显示的字符串进行编码.MapPath 返回与 Web 服务器上的指定 ...
- 前端javascript发送ajax请求、后台书写function小案例
HTML端页面: <td> <input class="pp_text" type="text" name="" valu ...
- c#生成随机数示例分享
c#生成(随机数 http://www.jbxue.com/tags/suijishu.html)的代码. /// 构造随机数 种子 ]; System.Security.Cr ...
- js闭包理解实例小结
Js闭包 闭包前要了解的知识 1. 函数作用域 (1).Js语言特殊之处在于函数内部可以直接读取全局变量 <script type="text/javascript"> ...
- Laravel 5 基础(十二)- 认证
Laravel 出厂已经带有了用户认证系统,我们来看一下 routes.php,如果删除了,添加上: Route::controllers([ 'auth' => 'Auth\AuthContr ...
- FileUpload控件「批次上传 / 多档案同时上传」的范例--以「流水号」产生「变量名称」
原文出處 http://www.dotblogs.com.tw/mis2000lab/archive/2013/08/19/multiple_fileupload_asp_net_20130819. ...
- Vmware下Ubuntu无法上网的问题
本来这个挺简单的个问题,但是由于很久没有使用虚拟机并且期间实体机网络环境发生了一些变化,导致了一些麻烦. 一般用NAT就行了,就是Vmware右下角那个图标(左起第4个)设置就行. 我这么设置了还是不 ...