我正在制作一个获取博客 JSON 内容的应用程序。博客文章的标题显示在 tableView 中。
获取的标题是 HTML 编码的。所以我用这段代码解码了它们
func configureCell(cell: UITableViewCell, atIndexPath indexPath: NSIndexPath) {
let object = self.fetchedResultsController.objectAtIndexPath(indexPath) as NSManagedObject
var encodedString = object.valueForKey("title")!.description
var encodedData = (encodedString as NSString).dataUsingEncoding(NSUTF8StringEncoding)
var attributedOptions = [NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType]
var attributedString = NSAttributedString(data: encodedData, options: attributedOptions, documentAttributes: nil, error: nil)
var decodedString = attributedString.string
cell.textLabel?.text = decodedString
// cell.detailTextLabel?.text = object.valueForKey("publishedDate")!.description
}
我可以完成解码,并且标题完美地显示在模拟器中。但控制台显示此错误ThisIsMe[6837:2029906] +[CATransaction synchronize] called within transaction
4 次。代码中没有其他错误,所有其他功能都运行良好。
请帮忙