源码来自:Zed Said Studio

//Define correct bundle for loading resources
NSBundle* bundle = [NSBundle bundleForClass:[ZSSRichTextEditor class]];

//Create a string with the contents of editor.html
NSString *filePath = [bundle pathForResource:@"editor" ofType:@"html"];
NSData *htmlData = [NSData dataWithContentsOfFile:filePath];
NSString *htmlString = [[NSString alloc] initWithData:htmlData encoding:NSUTF8StringEncoding];

//Add jQuery.js to the html file
NSString *jquery = [bundle pathForResource:@"jQuery" ofType:@"js"];
NSString *jqueryString = [[NSString alloc] initWithData:[NSData dataWithContentsOfFile:jquery] encoding:NSUTF8StringEncoding];
htmlString = [htmlString stringByReplacingOccurrencesOfString:@"<!-- jQuery -->" withString:jqueryString];

//Add JSBeautifier.js to the html file
NSString *beautifier = [bundle pathForResource:@"JSBeautifier" ofType:@"js"];
NSString *beautifierString = [[NSString alloc] initWithData:[NSData dataWithContentsOfFile:beautifier] encoding:NSUTF8StringEncoding];
htmlString = [htmlString stringByReplacingOccurrencesOfString:@"<!-- jsbeautifier -->" withString:beautifierString];

//Add ZSSRichTextEditor.js to the html file
NSString *source = [bundle pathForResource:@"ZSSRichTextEditor" ofType:@"js"];
NSString *jsString = [[NSString alloc] initWithData:[NSData dataWithContentsOfFile:source] encoding:NSUTF8StringEncoding];
htmlString = [htmlString stringByReplacingOccurrencesOfString:@"<!--editor-->" withString:jsString];

[self.editorView loadHTMLString:htmlString baseURL:self.baseURL];

从上面可以看出,在HTML中,写了要被替换的字符串“,然后用JS 替换。