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的更多相关文章

  1. NSString、NSMutableString基本用法

    NSString其实是一个对象类型.NSString是NSObject(Cocoa Foundation的基础对象)的子类 一.NSString的创建 1.创建常量字符串.NSString *astr ...

  2. NSString的常见方法

    //1.创建常量字符串. NSString *astring = @"This is a String!";   //2.创建空字符串,给予赋值. NSString *astrin ...

  3. iOS NSString的常用用法

    //1.创建常量字符串. NSString *astring = @"This is a String!";   //2.创建空字符串,给予赋值. NSString *astrin ...

  4. NSString 截取字符串

    NSString字符串常用方法2010-09-06 14:18/******************************************************************** ...

  5. NSString、NSMutableString基本使用

    郝萌主倾心贡献.尊重作者的劳动成果,请勿转载. 假设文章对您有所帮助.欢迎给作者捐赠,支持郝萌主.捐赠数额任意.重在心意^_^ 我要捐赠: 点击捐赠 Cocos2d-X源代码下载:点我传送 游戏官方下 ...

  6. NSString 练习

        //将“⽂文艺⻘青年”改成“213⻘青年”.   NSString *str = @"文艺青年";   NSString *str1 = [str stringByRepl ...

  7. NSString 字符串操作

    //一.NSString /*----------------创建字符串的方法----------------*/ //1.创建常量字符串. NSString *astring = @"Th ...

  8. NSString 用法大全。

    一.NSString 创建字符串.  NSString *astring = @"This is a String!"; 创建空字符串,给予赋值.  NSString *astri ...

  9. 转:用法总结:NSNumber、NSString、NSDate、NSCalendarDate、NSData(待续)

    NSNumber + (NSNumber *)numberWithInt:(int)value; + (NSNumber *)numberWithDouble:(double)value; - (in ...

随机推荐

  1. 10 Code Coverage Tools for C & C++

    Code coverage is a measure used in software testing that describes the degree to which the source co ...

  2. 【C++面试】常考题复习:排序算法

    // Sort.cpp : 定义控制台应用程序的入口点. // #include "stdafx.h" #include <stdlib.h> /*********** ...

  3. SVN创建资源与分支详解

    创建分支的意义: 简单说,分支就是用于区分开发版本与当前发布版本的. 1. 主干负责新功能的开发 2..分支负责修正当前发布版本的bug(对于可以放入下个发布版本的改进性bug可以直接在主干上开发) ...

  4. MySQL 5.7.9 免安装配置

    MySQL 5.7.9 免安装配置 环境:win10 64位 mysql版本:mysql-5.7.9-winx64.zip (http://dev.mysql.com/downloads/mysql/ ...

  5. CentOS 6.x版本升级Mysql

    首先确定一下自己的DNS  vi /etc/resolv.conf    我一般为114.114.114.114 #-----------------------------CentOS 6.x版本升 ...

  6. Data Mover Script Templates

    Datamover is probably the best way to export and import data between PeopleSoft databases and the sc ...

  7. 关于Ajax跨域

    本人因工作需求,编写了一个测试页面,在页面填写完信息之后去向一个站点请求数据,然后返回结果!一开始是直接用Ajax在脚本中去访问,没有大碍(因为目标地址是本机上的一个网站),但是当站点去外部的网站时, ...

  8. WinForm程序安装、发布流程

    一  签名 所谓签名就是给应用程序一个身份,申请一个专利.签名的时候需要选择证书.就向我们上学一样,得奖了老师给你发个证书.如果不进行签名,杀毒软件会把你打包后的exe文件作为病毒处理. 签名的步骤: ...

  9. 无需server-U IIS7.5 在已有的多个WEB网站上配置FTP发布

    1 新建一个用于ftp登陆的计算机用户. 操作:开始→管理工具→计算机管理→本地用户和组→用户,新建一个计算机用户,设置好用户名和密码,例如:nenkea nkscl 2 在web站点文件夹下,把新建 ...

  10. Lambda Grinding Miller From Zenith

    data = """ The Basic Things About Grinding Mill A grinding mill is a unit operation d ...