Skip navigation.
 
mlRe: Getting Image from Web and Displaying it problem
FROM : John Tsombakos
DATE : Fri Jan 24 15:57:53 2003

I did change the image loading code to use this. It's now:
- (IBAction)getImage:(id)sender
{
    NSImage *image = [[NSImage alloc]
initWithContentsOfURL:[NSURL
URLWithString:@"http://www.rccl.com/rc/image/vywebcam.jpg"]];
    if (image) {
        [voyagerImage setImage:image];
        [image release];
    } else {
        NSLog(@"Could not load image");
    }
}

I haven't seen the error message, but it could be just
it's been loading fine this morning. I'd still like to be
able to trap the bad-load.

One this I also did notice - I didn't have the release in
there originally, and I was watching the app using 'top'
in a terminal window. Every time I clicked the button, the
memory would go up. (Remember, Cocoa semi-newbie here) I
guessed that the image was being retained by the Imageview
and that I could release it like I do above. It didn't
crash, and the memory didn't creep up this time, so I
guess I assumed correctly.

(I've read pretty much all the articles on retain-release
and a couple Cocoa books, and understand the concept -
it's just figuring out actually when you should release,
like above yes you need to release the image, but the
string is autoreleased and I don't have to do it
explicitly)

Thanks again!

On Fri, 24 Jan 2003 14:27:33 +0100
  David Remahl <<email_removed>> wrote:
>Nope, it is perfectly ok to do:
>
>NSString *str = @"whatever";
>
>I'm not sure what the original poster's problem might be.
>The code looks ok. Are you sure the image you are
>downloading isn't corrupt?
>
>You could also try;
>
>NSImage *image = [[NSImage alloc]
>initWithContentsOfURL:[NSURL
>URLWithString@"http://www.rccl.com/rc/image/vywebcam.jpg"]];
>
>The image will then be downloaded from the URL
>automatically.

_______________________________________________
cocoa-dev mailing list | <email_removed>
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

Related mailsAuthorDate
mlGetting Image from Web and Displaying it problem John Tsombakos Jan 24, 06:22
mlRe: Getting Image from Web and Displaying it problem Scott Anguish Jan 24, 09:12
mlRe: Getting Image from Web and Displaying it problem mw Jan 24, 12:46
mlRe: Getting Image from Web and Displaying it problem David Remahl Jan 24, 14:27
mlRe: Getting Image from Web and Displaying it problem John Tsombakos Jan 24, 14:39
mlRe: Getting Image from Web and Displaying it problem John Tsombakos Jan 24, 15:57
mlRe: Getting Image from Web and Displaying it problem John Tsombakos Jan 24, 16:11
mlRe: Getting Image from Web and Displaying it problem David Remahl Jan 24, 16:44
mlRe: Getting Image from Web and Displaying it problem John Tsombakos Jan 24, 17:17