NSXMLParser解析器:parseErrorOccurred:未在iOS 7上调用 [英] NSXMLParser parser:parseErrorOccurred: not called on iOS 7

查看:162
本文介绍了NSXMLParser解析器:parseErrorOccurred:未在iOS 7上调用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

iOS7上有一个非常奇怪的问题。

I have a very strange issue on iOS7.

我使用标准的NSXMLParser。
在iOS6上一切正常 - 当XML有效时以及当NSData为零字节或包含无效字节时。

I use standard NSXMLParser. On iOS6 everything works just fine - when XML is valid as well as when NSData is zero bytes or contains invalid bytes.

self.dataParser = [[[NSXMLParser alloc] initWithData:data] autorelease];
[self.dataParser setDelegate: self];
[self.dataParser parse];

在iOS7解析器上只有在具有有效XML数据时才能正常工作。
如果数据是零字节,则不会调用任何委托方法。

On iOS7 parser works as expected only when it has a valid XML data. If data is zero bytes, none of the delegate methods are called.

请帮我找一个方向。谢谢。

Please help me find a direction to look to. Thanks.

UPD。
所有委托方法都已实现(它们在iOS6上运行良好)。
我可以检查数据是否包含非零字节(和data == nil),但我还必须处理无效的XML情况......

UPD. All delegate methods are implemented (they work well on iOS6). I could check if data contains non-zero bytes (and data == nil), but I also must handle non-valid XML situations...

推荐答案

似乎在iOS 7上解析器:parseErrorOccurred:当数据为零字节或在<无效时,不调用委托方法code> UTF8 编码。

It appears that on iOS 7 parser:parseErrorOccurred: delegate method is not being called when data is zero bytes or is not valid in UTF8 encoding.

对我来说,我不必使用 parserDidEndDocument:解析器:parseErrorOccurred:检测完成解析的方法,我只需检查 parse的返回值方法!

It became a revelation to me that I don't have to use parserDidEndDocument: and parser:parseErrorOccurred: methods to detect finish of parsing, I can just check return value of parse method!

就像我这些年来一直失明一样:)

It's like I've been blind all these years :)

Big感谢Martin R。

Big thanks to Martin R.

这篇关于NSXMLParser解析器:parseErrorOccurred:未在iOS 7上调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆