Re: NSImage initWithContentsOfURL
Re: NSImage initWithContentsOfURL
- Subject: Re: NSImage initWithContentsOfURL
- From: John Nikolai <email@hidden>
- Date: Wed, 23 Jan 2002 16:57:39 -0800
Hi Matt,
Thanks for the pointer! It works like a champ...
I had to change the code a bit to get it to compile w/o warnings:
image = [[NSImage alloc] initWith
Data:[url resourceDataUsingCache:YES]];
Note that initWithData: is not a class method. At least not in the
current framework I have installed.
Thanks again,
- John
On Wednesday, January 23, 2002, at 03:45 PM, Matt Judy wrote:
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 initWithData:[url
resourceDataUsingCache:YES]];
--Matt
_______________________________________________
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.