• 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: Getting Image from Web and Displaying it problem
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Getting Image from Web and Displaying it problem


  • Subject: Re: Getting Image from Web and Displaying it problem
  • From: "John Tsombakos" <email@hidden>
  • Date: Fri, 24 Jan 2003 11:17:38 -0500

I did change back to the original code and it does refresh. I still am getting the "..not enough scanlines.." message occasionally. So the question on how to deal with that is still open.

Also, in the original code, I change the relevent bits to:

[voyagerImage setImage:image];
[image release]; // added
[imageData release]; // added but...

With the second release in there, the app blew chunks when I ran it (exited due to signal 11 (SIGSEGV). I removed the second release and it ran fine.

Ok now I'm back to being lost about retain/release. I displayed the retainCount of the imageData object and after the line

NSImage* image = [[NSImage alloc] initWithData:imageData];

the count of imageData goes to 2. Looking at the docs of resourceDataUsingCache: doesn't tell me whether or not I need to release or not, neithe rdoes initWithData.

I am assuming (not to confidently) that the string (NSString* string = @"xxx") is autoreleased and I don't have to worry about it?

Thanks again (again)!


On Fri, 24 Jan 2003 16:44:04 +0100
David Remahl <email@hidden> wrote:
Oh, I didn't consider that. initWithContentsOfURL: apparently uses the cache. You should go back to using your old method of first loading an NSData and then initing the image with that.

You are doing the right thing, releasing the image after setting the image view image. The image view will retain the image, so it is safe for you to release it. Since you alloced it, you need to release it.

/ Regards, David

Hmm. Spoke too soon. The below code works - the first time. When I click the button to reload the image, it doesn't load the updated image (which I know has changed by looking at the original website). The old code does refresh the image. It must be caching it somewhere and not reloading it.

On Fri, 24 Jan 2003 14:27:33 +0100
David Remahl <email@hidden> 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@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.

References: 
 >Re: Getting Image from Web and Displaying it problem (From: David Remahl <email@hidden>)

  • Prev by Date: Re: Core Graphics -> PostScript
  • Next by Date: Handling NSWorkspace: -openUrl: message?
  • Previous by thread: Re: Getting Image from Web and Displaying it problem
  • Next by thread: A good method for xml usage/parsing
  • Index(es):
    • Date
    • Thread