Re: Can't set image in NSImageView
Re: Can't set image in NSImageView
- Subject: Re: Can't set image in NSImageView
- From: Fritz Anderson <email@hidden>
- Date: Fri, 6 Feb 2004 23:35:35 -0600
You cannot change an NSString into an NSImage by taking a pointer to
the NSString and using a cast to call it a pointer-to-NSImage. That
just mislabels the pointer.
If you have a file name, and want to turn it into an NSImage, have a
look at the documentation for NSImage. You will want to allocate one,
and then initialize it with the contents of a file. Hunt through the
documents for something to do that.
-- F
On 6 Feb 2004, at 10:59 PM, email@hidden wrote:
I have the following routine in my app that exicutes when a button is
clicked.
_______________________________________________
- (IBAction)mystart:(id)sender
{
// [statusImage setImage:@"onstate.png"]; // doesn't work
NSString *myImage;
myImage = @"onstate.png";
[statusImage setImage:(NSImage *)myImage];
[actionButton setTitle:@"Stop"];
[actionButton setAction:@selector(mystop:)];
}
_______________________________________________
When the button is clicked, it doesn't change the image and gives the
following errer.
2004-02-06 23:50:05.953 XSKeyEMU[21019] NSImageCell's object value
must be an
NSImage.
_______________________________________________
I have looked at the information on NSImageView's "setImage"
setImage:
- (void)setImage:(NSImage *)image
Lets you specify the image the receiver displays.
See Also: - image
_______________________________________________
and it doesn't say much about it, any ideas what the problem is and a
solution?
_______________________________________________
Dale
_______________________________________________
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.
_______________________________________________
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.