• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: NSImage initWithContentsOfURL
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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] initWithData:[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.


  • Follow-Ups:
    • Re: NSImage initWithContentsOfURL
      • From: Matt Judy <email@hidden>
References: 
 >Re: NSImage initWithContentsOfURL (From: Matt Judy <email@hidden>)

  • Prev by Date: Perl
  • Next by Date: Re: NSImage initWithContentsOfURL
  • Previous by thread: Re: NSImage initWithContentsOfURL
  • Next by thread: Re: NSImage initWithContentsOfURL
  • Index(es):
    • Date
    • Thread