我很累,不知道发生了什么。
private var _parser: XMLParser = XMLParser();
public var delegate: ModelFactoryDelegate?;
override internal func response() -> Bool
{
print("SessionFactory::response(1)");
self._parser = XMLParser(data: self._content.content);
print("SessionFactory::response(2)");
self._parser.delegate = self;
print("SessionFactory::response(3)");
self._parser.parse();
print("SessionFactory::response(4)");
self.close(nil);
print("SessionFactory::response(5)");
return true;
}
func parser(_ parser: XMLParser, didStartElement elementName: String, namespaceURI: String?, qualifiedName qName: String?, attributes attributeDict: [String : String])
{
print("ModelFactory::parser(1)");
if (elementName == "id") {
self._mark = true;
print("ModelFactory::parser(2)");
}
print("ModelFactory::parser(3)");
}
func parser(_ parser: XMLParser, didEndElement elementName: String, namespaceURI: String?, qualifiedName qName: String?)
{
}
func parser(_ parser: XMLParser, foundCharacters string: String)
{
if (self._mark) {
if (self.delegate != nil) {
print("ModelFactory::parser(4)");
self.delegate!.onInit(id: AIndex(string.trimmingCharacters(in: .newlines))!);
print("ModelFactory::parser(5)");
}
self._mark = false;
}
}
输出
AceController::onNextButtonTouchUpInside(1)
HTTPSocket::receive(1)
HTTPSocket::receive(2)
SessionFactory::response(1)
SessionFactory::response(2)
SessionFactory::response(3)
AceController::onInit(1)
Session::open(1)
为什么.parse()可以停止执行?
任何想法都会受到赞赏。