Hello,
I'm having a problem with initWithHTML (from NSAttributedString) in Tiger. In my app I try to convert a string that contains html code, but when use this method, my application would hang and stop doing anything.
This is the code I'm using:
NSAttributedString *string = [[[NSAttributedString alloc] initWithHTML:[content dataUsingEncoding:[content fastestEncoding]] options:nil documentAttributes:NULL] autorelease];
When using the debugger, I hit pause and this is the backtrace:
#0 0x9000a778 in mach_msg_trap #1 0x9000a6bc in mach_msg #2 0x9074a4d8 in __CFRunLoopRun #3 0x90749ddc in CFRunLoopRunSpecific #4 0x9288b244 in -[NSRunLoop runMode:beforeDate:] #5 0x93838838 in -[NSHTMLReader _loadUsingWebKit] #6 0x9383811c in -[NSHTMLReader attributedString] #7 0x938376b8 in _NSReadAttributedStringFromURLOrData #8 0x93835e1c in -[NSAttributedString(NSAttributedStringKitAdditions) initWithData:options:documentAttributes:error:] #9 0x000d0b74 in -[XMLFeedArticle content] at XMLFeedArticle.m:46
I don't know if this has something to do with, but the string is retrieved from an XML document, I use NSXMLParser to parse the document. When I come across some CData I do the following:
- (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *s = [[NSString alloc] initWithData:CDATABlock encoding:NSISOLatin1StringEncoding]; ...
Thanks in advance |