我已按照以下链接的“使用”部分下的步骤添加了第 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;
有帮助吗?

解决方案 2

固定它!!我只需要在我的应用程序目标下,在“链接二进制与库”部分下添加“libdtcoreText.a”静态库

其他提示

也许尝试改变 initWithHTMLDatainitWithHTML?所以像这样:

NSAttributedString *string = [[NSAttributedString alloc] initWithHTML:data documentAttributes:NULL];

我不认为有你所说的方法。

我说的方法可以找到 在这个链接.

除了jerry的确保libdtcoreText.a的回答之外,可能需要的另一个修复程序链接在项目的构建设置下,将“-objc”添加到其他链接器标志。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top