Can't Cache Image Error Message

Discussion in 'Mac Programming' started by Spike099, Jul 2, 2007.

  1. macrumors regular

    Feb 18, 2007
    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
    2007-07-02 23:32:31.184 ImageApp[869] Can't cache image

    It appears the image is there as it shows the dimensions.
  2. Moderator emeritus


    Jun 15, 2000
    Is imageView connected in Interface Builder? Try a NSLog(@"%@", imageView); and see if that comes out null.
  3. thread starter macrumors regular

    Feb 18, 2007
    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.

Share This Page