Re: NSImage initWithContentsOfURL
Re: NSImage initWithContentsOfURL
- Subject: Re: NSImage initWithContentsOfURL
- From: Matt Judy <email@hidden>
- Date: Wed, 23 Jan 2002 15:45:06 -0800
John Nikolai wrote:
> ----------
> NSURL *url = [NSURL
> URLWithString:@"
http://www.google.com/images/logo.gif"];
> image = [[NSImage alloc] initWithContentsOfURL: url];
> ----------
You're right. That code doesn not work, but it's not your fault. It's
a bug in NSImage. You can't use initWithContentsOfURL:.
Instead, do this:
NSURL *url = [NSURL URLWithString:@"
http://www.google.com/images/logo.gif"];
NSImage *image = [NSImage initWith
Data:[url resourceDataUsingCache:YES]];
--Matt