PDA

View Full Version : Can't Cache Image Error Message




Spike099
Jul 2, 2007, 10:41 PM
Hey guys,

I am simply trying to display an image and can't figure out the issue.

In my appController.m

person = [personController objectAtIndex:x];
NSImage *portrait = [[NSImage alloc] init];
portrait = [person valueForKey:@"portrait"];

NSSize size = [portrait size]; // testing purposes
NSLog(@"Image Size \n X:%f\n Y:%f", size.width, size.height);

[imageView setImage:portrait];
[imageView setNeedsDisplay:YES];


In the Person.m file.

- (void)setPortrait:(NSImage *)newImage
{
[newImage retain];
[portrait release];
portrait = newImage;
}
- (NSImage *)portrait
{
return portrait;
}

So... I've been trying to solve this one for awhile now. Just can't do it. The log shows the following.

2007-07-02 23:32:31.183 ImageApp[869] Image Size
X:128.000000
Y:192.000000
2007-07-02 23:32:31.184 ImageApp[869] Can't cache image

It appears the image is there as it shows the dimensions.



kainjow
Jul 2, 2007, 11:13 PM
Is imageView connected in Interface Builder? Try a NSLog(@"%@", imageView); and see if that comes out null.

Spike099
Jul 3, 2007, 07:01 AM
Ooooh!!! I got it. The Can't Cache Image was due to me trying to reflect the wrong image. Aswell, I had not incremented my counter in my while loop, so it was constantly trying to display when x=0. But an error would get generated in that while loop so it would stop which made it look as though there was no loop problem.

Thanks kainjow, this issue was more me been a messy programmer while I learn. Gonna have to clean up my code and do some commenting before I continue now.