NSString *filePath = [[NSBundle mainBundle] pathForResource:@"about" ofType:@"txt"];
if (filePath) {
NSString *content = [NSString stringWithContentsOfFile:filePath];
if (content) {
textView.text= content;
}
For loading HTML data into file
NSString *filePath = [[NSBundle mainBundle] pathForResource:@"about" ofType:@"html"];
if (filePath) {
NSString *content = [NSString stringWithContentsOfFile:filePath];
if (content) {
NSAttributedString *attributedString = [[NSAttributedString alloc] initWithData:[content dataUsingEncoding:NSUnicodeStringEncoding] options:@{ NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType } documentAttributes:nil error:nil];
textView.attributedText = attributedString;
}
}
No comments:
Post a Comment