Re: NSURL Tutorial?
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]] initWith
Data:lData];
[mImageViewOutlet setImage:lImage];
[lImage release]; // retained by NSImageView
[lURL release]; // no longer needed
Steve