Friday, 15 March 2013

ios - When should you call NSXMLParser.parse() on your NSStream? -



ios - When should you call NSXMLParser.parse() on your NSStream? -

i have nsxmlparser object. i'm running xmpp stream.

does .parse() need called each time receive message or once?

here's parse of relevant code in 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 }

.parse() synchronous operation, block until has parsed entire stream. you'll have phone call parse different thread (or dispatch queue), or schedule input stream in different runloop.

see here how create dispatch queue parser, , here how utilize input stream different queue.

ios swift xmpp nsstream

No comments:

Post a Comment