我一直在尝试在我的文本视图中格式化一个字符串,但我无法解决。我对 xcode 很陌生。
我在这个文件中遗漏了什么吗?我一直在查看堆栈,这就是您的操作方式..但它不起作用。
- (NSString *)stripTags:(NSString *)str
{
NSMutableString *html = [NSMutableString stringWithCapacity:[str length]];
NSScanner *scanner = [NSScanner scannerWithString:str];
scanner.charactersToBeSkipped = NULL;
NSString *tempText = nil;
while (![scanner isAtEnd])
{
[scanner scanUpToString:@"<" intoString:&tempText];
if (tempText != nil)
[html appendString:tempText];
[scanner scanUpToString:@">" intoString:NULL];
if (![scanner isAtEnd])
[scanner setScanLocation:[scanner scanLocation] + 1];
tempText = nil;
}
return html;
}
- (void)viewDidLoad
{
[super viewDidLoad];
NSString *str = newsArticle;
descTextView.text = [NSString stringWithString:str];
// Do any additional setup after loading the view from its nib.
}