Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Spike099

macrumors regular
Original poster
Feb 18, 2007
143
0
Canada
Hey guys,

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

In my appController.m

Code:
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.

Code:
- (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

Moderator emeritus
Jun 15, 2000
7,958
7
Is imageView connected in Interface Builder? Try a NSLog(@"%@", imageView); and see if that comes out null.
 

Spike099

macrumors regular
Original poster
Feb 18, 2007
143
0
Canada
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.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.