Solution: Why doesn't this work? (NSURL loadResourceDataNotifyingClient)
Solution: Why doesn't this work? (NSURL loadResourceDataNotifyingClient)
- Subject: Solution: Why doesn't this work? (NSURL loadResourceDataNotifyingClient)
- From: Gerben Wierda <email@hidden>
- Date: Fri, 1 Mar 2002 12:24:26 +0100
I found the answer. It turns out that NSURL
loadResourceDataNotifyingClient does not use protocol NSURLHandleClient
but the simpler informal protocol NSURLClient.
G
On Thursday, February 28, 2002, at 11:26 , Gerben Wierda wrote:
The rogram below is meant to demonstrate something I probably do not
understand. The same behaviour i see in an AppKit app I am building).
The code contains a class (MyClient) that conforms to the
NSURLHandleClient protocol. The methods do not do anything useful, but
they NSLog their name. I load an URL with
loadResourceDataNotifyingClient and give a created MyClient object as
client. I expect the methods to display their Log messages, but they do
not. Why does this notw ork?
G
=================== start file urltest.m
/* to compile:
cc -Wall -framework Foundation urltest.m -o urltest
*/
#define MYHTTPURL @"http://bloch.ling.yale.edu/~gerben/TeXLive-
bin.ii/TeXLive-bin.rtf"
#import <Foundation/Foundation.h>
@interface MyClient: NSObject<NSURLHandleClient> {
}
@end
@implementation MyClient
- (void)URLHandle:(NSURLHandle *)sender
resourceDataDidBecomeAvailable:(NSData *)newBytes
{
NSLog(@"resourceDataDidBecomeAvailable");
}
- (void)URLHandleResourceDidBeginLoading:(NSURLHandle *)sender
{
NSLog(@"URLHandleResourceDidBeginLoading");
}
- (void)URLHandleResourceDidFinishLoading:(NSURLHandle *)sender
{
NSLog(@"URLHandleResourceDidFinishLoading");
}
- (void)URLHandleResourceDidCancelLoading:(NSURLHandle *)sender
{
NSLog(@"URLHandleResourceDidCancelLoading");
}
- (void)URLHandle:(NSURLHandle *)sender
resourceDidFailLoadingWithReason:(NSString *)reason
{
NSLog(@"resourceDidFailLoadingWithReason");
}
@end
int main (int argc, const char * argv[])
{
NSAutoreleasePool * pool;
NSURL *httpurl;
MyClient *client;
pool = [NSAutoreleasePool new];
client = [[MyClient alloc] init];
httpurl = [NSURL URLWithString:MYHTTPURL];
[httpurl loadResourceDataNotifyingClient:client usingCache:NO];
NSLog( @"loadResourceDataNotifyingClient");
getchar();
[pool release];
}
_______________________________________________
MacOSX-dev mailing list
email@hidden
http://www.omnigroup.com/mailman/listinfo/macosx-dev
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.