Programming

Objective C iOS NSXMLParser does not support reentrant parsing
  • 1# JDP
  • 321302015-12-24 12:52:49
iOS8後會碰到 NSXMLParser does not support reentrant parsing 的問題,造成錯誤無法執行。

只要使用 dispatch_queue 另開Thread去執行parse即可解決:
            dispatch_queue_t reentrantAvoidanceQueue = dispatch_queue_create("reentrantAvoidanceQueue", DISPATCH_QUEUE_SERIAL);
            dispatch_async(reentrantAvoidanceQueue, ^{

            self._tmpXMLString = [[NSMutableString alloc] init];
            xmlParserS = [[NSXMLParser alloc]initWithData:[request responseData]];
            xmlParserS.delegate = self;
            [xmlParserS parse];
            });
            dispatch_sync(reentrantAvoidanceQueue, ^{ });


Reference:
http://www.4byte.cn/question/238 ... ntrant-parsing.html
http://www.bubuko.com/infodetail-567603.html
倒序瀏覽 看全部 全部回復
暫無回復,快來搶沙發
回復 收藏 轉播 分享 淘帖