SWIFT:+[CATransaction 同步] 在解码 HTML 实体时在事务中调用

SWIFT: +[CATransaction synchronize] called within transaction while decoding HTML entities

我正在开发一个可以获取博客 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 次。代码中没有其他错误,所有其他功能都运行良好。

请帮忙

在解码 HTML 个实体时出现此问题,因此我寻找另一种解码方法并使用了以下代码:

 func configureCell(cell: UITableViewCell, atIndexPath indexPath: NSIndexPath) {
                let object = self.fetchedResultsController.objectAtIndexPath(indexPath) as NSManagedObject


      let eTitle:NSString = object.valueForKey("title")!.description
      let deTitle  = eTitle.stringByDecodingHTMLEntities()
      cell.textLabel?.text = deTitle
}

早些时候,stringByDecodingHTMLEntities() 丢失了。所以我采取了这种方法。

注意:要获取 stringByDecodingHTMLEntities() 我们需要导入 NSString+HTML.h,从这里 NSString category for HTML