我有一个NSXMLParser对象。我正在运行XMPP流。
每次收到邮件或只收到一次邮件时,是否需要调用.parse()
?
这是NSStream中相关代码的解析:
func connectToSocket(host: String, port: Int) {
NSStream.getStreamsToHostWithName(host, port: port, inputStream: &(self.input), outputStream: &(self.output))
self.input!.delegate = self
self.output!.delegate = self
//self.input!.scheduleInRunLoop(NSRunLoop.mainRunLoop(), forMode: NSDefaultRunLoopMode)
//self.output!.scheduleInRunLoop(NSRunLoop.mainRunLoop(), forMode: NSDefaultRunLoopMode)
self.input!.scheduleInRunLoop(NSRunLoop.currentRunLoop(), forMode: NSDefaultRunLoopMode)
self.output!.scheduleInRunLoop(NSRunLoop.currentRunLoop(), forMode: NSDefaultRunLoopMode)
self.input!.open()
self.output!.open()
parser = NSXMLParser(stream: input!)
parser!.delegate = self
}