• 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: NSURL Tutorial?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSURL Tutorial?


  • Subject: Re: NSURL Tutorial?
  • From: "Steven W. Riggins" <email@hidden>
  • Date: Sun, 28 Oct 2001 13:46:48 -0800

At 2:36 PM -0500 10/28/01, Brian Moore wrote:
>Can anyone help me on how to use NSURL to retrieve an image of the net and display it into a NSImageView? It's probably very simple, but I am somewhat new to cocoa and would appreciate some help..

Brian,

I am writing this app as we speak :) Its fairly easy, but due to some bugs in the NSURL collection of classes, there are memory leaks. I am getting some help to work around these, so when I have it all working, will let you know.

Ignoring the bugs, this will work: (add your own error checking)

NSURL *lURL;
NSData *lData;
NSImage *lImage;

lURL = [[NSURL alloc] initWithString:@"http://www.whereever.com/image.jpg";];
lData = [lURL resourceDataUsingCache:NO];
lImage = [[NSImage allocWithZone:[self zone]] initWithData:lData];


[mImageViewOutlet setImage:lImage];

[lImage release]; // retained by NSImageView
[lURL release]; // no longer needed


Steve


References: 
 >NSURL Tutorial? (From: Brian Moore <email@hidden>)

  • Prev by Date: Re: Changing the header size of a NSTableView
  • Next by Date: Re: NSURL Tutorial?
  • Previous by thread: Re: NSURL Tutorial? (oops, answer part 2)
  • Next by thread: Re: NSURL Tutorial?
  • Index(es):
    • Date
    • Thread