• 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: 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 initWithData:[url resourceDataUsingCache:YES]];

--Matt


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

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