【发布时间】:2015-02-06 04:02:04
【问题描述】:
#import <Foundation/Foundation.h>
int main(int argc, const char * argv[]) {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc]init];
NSString *dog=@"Hotdog? I thought you said hotfrog!";
NSMutableString *mute;
mute = [NSMutableString stringWithString:dog];
NSLog(@"%@", mute);
[mute setString:@"I am a new string "];
NSLog(@"%@", mute);
[mute replaceCharactersInRange: NSMakeRange(11, 12) withString: @"mother"];
NSLog(@"%@", mute);
[pool drain];
return 0;
}
【问题讨论】:
-
它肯定会给你一个错误,因为你的
mute字符串长度是 17 并且你的范围指示起始范围是从 11 到 23 (11+12)。
标签: objective-c replace nsstring