How to insert a character into a NSString
2014-07-14 14:39
381 查看
How do I insert a space to a NSString.
I need to add a space at index 5 into:
To get this result:
with:
You need to use NSMutableString
[/code]
or you could use those method to split your string :
and recombine them after with
http://stackoverflow.com/questions/8722051/how-to-insert-a-character-into-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
[/code]
NSMutableString *mu = [NSMutableString stringWithString:dir]; [mu insertString:@" " atIndex:5];
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 save SQL Server data as Insert INTO SQL Script
- API-Examples To howto Insert into Transaction Open Interface
- How to Insert Values into an Identity Column in SQL Server
- Examples To howto Insert into Transaction Open Interface
- How to disable autosize function when insert a object into powerpoint(Powerpoint中插入对象时如何关闭自动调整尺寸和布局功能)
- How to check if NSString begins with a certain character
- How to get a Chinese character's PinYin automaticly?
- how to test the real character number if the string include chinese character,notice one chinese character only calculater one b
- How to install the glut libraries and dll's into windows
- how to add a member into the PDS using JCL
- 如何使用SSH向IPOD Touch2传输文件 - How to SSH into iPod Touch 2G [Transfer Files, Apps via SSH Access] 如何使用SSH向IPOD Touch2传输文件 - How to S
- How to freeze a dynamic aspx page into a static html page (on the server).(转:http://codebetter.com/blogs/peter.van.ooijen/archiv
- HOW TO: How to import UUID function into Postgre 9.3
- How to deal with "Incorrect NSStringEncoding value 0×0000 Error with ASIHTTPRequest" problem?
- Drill Into .NET Framework Internals to See How the CLR Creates Runtime Objects
- How to burn big .iso file into disks?
- How to insert double and float values to sqlite?如何向sqlite插入double和float型数据
- How to add MFC Common class into your application based on SDK?
- How to use .NET Windows Control into the WPF Application
- How to convert a TTF character to an 8bpp BMP file