NSImage lazy initialization
NSImage lazy initialization
- Subject: NSImage lazy initialization
- From: Mark Rowe <email@hidden>
- Date: Fri, 31 Jan 2003 20:18:16 +1300
Hello,
The documentation for NSImage's initByReferencingURL: says
Initializes the receiver, a newly allocated NSImage instance, for the
file at url. This method initializes lazily: The NSImage doesn't
actually open url or create image representations from its data until
an application attempts to composite or requests information about the
NSImage.
From this I infer that the image data is not downloaded from the
Internet until a method that requires it be present is called. In
reality, this does not seem to be the case. The code below is what I
am using to try this. The program blocks on the call to
initByReferencingURL until the image data has been retrieved. Does
anyone have some advice on this matter?
- (id) init
{
NSLog(@"-[Test init]");
if (![super init])
return nil;
_img = [[NSImage alloc] initByReferencingURL:[NSURL
URLWithString:@"
http://www.megatokyo.com/strips/0101.gif"]];
[_img setDelegate:self];
return self;
}
Mark Rowe
_______________________________________________
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.