我已按照以下链接的“使用”部分下的步骤添加了第 3 方库作为子项目
http://cocoanetics.github.com/DTCoreText/
但是,添加子项目后,我的项目可以正确构建,但是我无法调用子项目中定义的任何方法,并且出现以下错误:
[NSConcreteAttributedString initWithHTMLData:documentAttributes:]: unrecognized selector
sent to instance 0x71141e0
2012-10-01 17:34:30.600 final_try[7785:11303] *** Terminating app due to uncaught
exception NSInvalidArgumentException', reason: '-[NSConcreteAttributedString
initWithHTMLData:documentAttributes:]: unrecognized selector sent to instance 0x71141e0
*** First throw call stack:
(0x1971012 0x1796e7e 0x19fc4bd 0x1960bbc 0x196094e 0x22a4 0x1f1e 0x6db7b7 0x6dbda7
0x6dcfab 0x6ee315 0x6ef24b 0x6e0cf8 0x1deedf9 0x1deead0 0x18e6bf5 0x18e6962 0x1917bb6
0x1916f44 0x1916e1b 0x6dc7da 0x6de65c 0x1c9d 0x1bc5 0x1)
libc++abi.dylib: terminate called throwing an exception
实现文件有以下代码:
NSString *fileName = [[NSBundle mainBundle] pathForResource:@"mailBody1" ofType:@"txt"];
NSString *str1 = [NSString stringWithContentsOfFile:fileName encoding:NSUTF8StringEncoding error:nil];
str1 = [str1 gtm_stringByUnescapingFromHTML];
NSData *data = [str1 dataUsingEncoding:NSUTF8StringEncoding];
_html = str1;
NSAttributedString *string = [[NSAttributedString alloc] initWithHTMLData:data documentAttributes:NULL];
NSLog(@"%@",[string plainTextString]);
NSLog(@"%@",string);
return self;