开发者

Is there a way to break NSXMLParser on a condition?

I have a simple question about nsxmlparser.

This is my snippet

- (void) parser: (NSXMLParser *) parser foundCharacters: (NSString 开发者_运维知识库*) string{
    [...]
    if ([currentElement isEqualToString:@"openpos"]) {
        if ([string isEqualToString:@"0"]) {
            // I WOULD EXIT FROM LOOP HERE!
            return;
        }
    }
    [...]
}

why this return doesn't work?

I need to exit from parser method and return back to my class with an error!

I need to force an exception? or there is a better way to break parser loop?

thanks,

alberto


Try [parser abortParsing]; before return;

From the docs: If you invoke this method, the delegate, if it implements parser:parseErrorOccurred:, is informed of the cancelled parsing operation.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜