Skip navigation.
 
mlNSImage lazy initialization
FROM : Mark Rowe
DATE : Fri Jan 31 23:00:19 2003

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


Related mailsAuthorDate
mlNSImage lazy initialization Mark Rowe Jan 31, 23:00
mlRe: NSImage lazy initialization Steve Dekorte Feb 1, 01:14