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

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_removed>> 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_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