【发布时间】:2012-08-06 06:20:07
【问题描述】:
我以某种方式错误地使用了 stringByReplacingCharactersInRange,但我不明白怎么做。我的目标是将NSString 的一个字符替换为另一个字符。我这样做了很多次,但是在两次替换后它从 NSString 的末尾开始切割,我不想要这个。这是我的代码。
NSRange firstCharRange = NSMakeRange(mi, mi); // mi is an int, indicating the index of the replaced char
myword = [myword stringByReplacingCharactersInRange:firstCharRange withString:bb.titleLabel.text]; // myword is the string
最初myword是@"RRRRRRRR",替换第一个字符串后变成了
eRRRRRRR
然后
egRRRRRR
然后
eghRRRR // why did cut off the last character?
【问题讨论】:
标签: iphone objective-c xcode ipad nsstring