I thought the same when I first read the documentation, and have tried not making ContentParser the delegate of the input stream as well as removing the call to -[NSXMLParser parse], however I still don't see any of the NSXMLParser delegates being called. I'm wondering if it's a run loop issue, and the delegates are not in the same thread the input stream and therefore don't get called? I don't know of any way to test which thread the stream is in or how to place the delegates in a different thread? ---------------------------------------- > Subject: Re: NSXMLParser and initWithStream > From: [email protected] > Date: Mon, 28 May 2012 07:44:16 -0500 > CC: [email protected] > To: [email protected] > > On 27 May 2012, at 7:14 PM, John Drake wrote: > > > Looking at the documentation for NSXMLParser, it seems like the > > initWithStream: method to initialize a NSXMLParser would be the perfect > > solution to my problem. I can initialize the parser with a NSInputStream > > and then call the parse method on NSXMLParser whenever I receive data over > > my socket which should in turn call the NSXMLParser delegates. > > The documentation for -[NSXMLParser -initWithStream:] is sparse, but I see > that the description is "Initializes the receiver with the XML contents from > the specified stream _and parses it_" [EA]. I guess that there should be no > need to call -[NSXMLParser parse] on the incoming data; the whole point of > hooking the parser up to a stream should be that you don't have to manage the > stream yourself, right? > > > However, I'm not seeing any of the delegates being called, the only method > > I see being called is the stream delegate stream:handleEvent:. > > > I wonder if it's productive to make your ContentParser the delegate** of the > input stream. It's the NSXMLParser that's interested in the incoming data. > The convention in the Delegate pattern is that objects have at most one > delegate. I do wonder why your setting of .delegate persists after you pass > the stream into the parser. > > — F > > ** In Cocoa parlance, a "delegate" is an object that implements the methods > of a delegate protocol (in this case your ContentParser is the delegate of > the parser). The methods themselves are "delegate methods." The latter term > may be awkward, but "delegate" has to be saved for "the object to which > functionality is delegated." > > -- > Fritz Anderson > Xcode 4 Unleashed: Don't bring your bathroom copy into the kitchen — were you > raised in a barn? > <http://x4u.manoverboard.org/> > _______________________________________________
Cocoa-dev mailing list ([email protected]) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [email protected]
