NSAttributedString from HTML in the background thread

后端 未结 2 1649
臣服心动
臣服心动 2020-12-19 06:58

What I need is to create NSAttributedString objects from relatively big HTML strings and store them (NSAttributedString-s) in the database. And of course I woul

2条回答
  •  無奈伤痛
    2020-12-19 07:57

    Yes you can't it in a background thread only on main thread. Use Oliver Drobnik's NSAttributedString+HTML class.

    Code would be something like this -

    NSMutableAttributedString *attrStr = [[NSMutableAttributedString alloc] initWithHTML: dataUsingEncoding:NSUTF8StringEncoding] documentAttributes:nil];
    

    Link - https://github.com/InfiniteLoopDK/NSAttributedString-Additions-for-HTML/blob/master/Classes/NSAttributedString%2BHTML.m

提交回复
热议问题