Re: dataWithContentsOfURL
Re: dataWithContentsOfURL
- Subject: Re: dataWithContentsOfURL
- From: Marc Laffitte <email@hidden>
- Date: Thu, 8 Nov 2001 10:22:49 +0100
Hi
You have to implement
- (void)URLResourceDidFinishLoading:(NSURL *)sender
{
// 'sender' is the NSURL object you used for starting donwload
// use sender to use your data. For instance:
NSDictionary * tDict = [NSDictionary
dictionaryWithContentsOfURL:sender];
// if the data you got is a dictionary, or any
xxxWithContentsOfURL message of your class of interest.
}
and the other related messages you are interested in, in the class
pointed by 'self'.
To save data chunk by chunk while it is loading, you could use the
'newBytes' argument if you implement:
- (void)URL:(NSURL *)sender resourceDataDidBecomeAvailable:(NSData
*)newBytes
Instead of 'self' in
[myNSURL loadResourceDataNotifyingClient:self usingCache:NO];
your could write
[myNSURL loadResourceDataNotifyingClient:myCustomClassInstance
usingCache:NO];
and implement those messages in the implementation of the class
myCustomClassInstance belongs to.
Then, your functions (I mean "messages") will be called at appropriate
times.
I did not experiment with the option usingCache:YES, but it should make
no difference.
On jeudi, novembre 8, 2001, at 05:56 , Angela Brett wrote:
Hi!
You may send the loadResourceDataNotifyingClient:usingCache: message
to an NSURL instance.
Then you will get resourceDidFailLoadingWithReason: messages if
appropriate.
I tried that with loadResourceDataNotifyingClient:self usingCache:YES
but never got resourceDidFailLoadingWithReason: or any of the other
messages defined in the NSURLHandleClient protocol. What could be going
wrong?
_______________________________________________
cocoa-dev mailing list
email@hidden
http://www.lists.apple.com/mailman/listinfo/cocoa-dev