Re: Cocoa Equivalent to BufferedStreamReader?
Re: Cocoa Equivalent to BufferedStreamReader?
- Subject: Re: Cocoa Equivalent to BufferedStreamReader?
- From: Dan Wood <email@hidden>
- Date: Tue, 06 Nov 2001 21:51:59 -0800
I think that in order to get that kind of control, the best bet
would be to write a subclass of NSURLHandle and have it message the
client for every byte or line received.
You can take a look at curlhandle
<
http://curlhandle.sourceforge.net/> as a starting point, but then
plug in your own customized reading routine.
The Java method you describe seems a lot more simple. However,
since the "chunks" of data you get are bigger than you'd want, but
coming through quickly enough, you could always provide your
feedback by scanning each chunk of data received, and react as if
it had just come in through loading. My guess is that from a user
perception point of view, it would be equivalent....
Dan
On Tuesday, November 6, 2001, at 07:39 PM, Jeff LaMarche wrote:
Right now I've got a very thread that simply loads an NSData from
an internet URL, like so:
thumbData = [NSData dataWithContentsOfURL:thumbURL];
[thumbData retain];
It works fine, but it's limited - I can't provide any feedback
concerning how much has been downloaded, nor can I kill the
thread. I read through the NSURL and NSURLHandle docs, and while I
see some alternative mechanisms of doing the same thing, they all
seem to leave all the work to Cocoa classes. NSURLHandle has a
mechanism for killing a load that's being done in the background
but that's still not as much control as I'd like.
Is there anything that allows you to read the data from a URL
line-by-line or byte-by-byte in a loop so that you can provide
some feedback about the progress and offer a way to cancel the
load? In Java, IIRC, you can load data from a URL using a
BufferedStreamReader or IOReader or one of the various reader
classes (don't remember which one, that's what JavaDoc is
for =) ), which allows you to stop loading after the current chunk.
Any suggestions or help is, as always, appreciated.
Jeff
_______________________________________________
cocoa-dev mailing list
email@hidden
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
--
Dan Wood
email@hidden
http://www.karelia.com/
http://www.bikealameda.org/
Mac OS X Developer: Online Resume:
http://www.karelia.com/resume.html