Problem with multiple instances of a nib
Problem with multiple instances of a nib
- Subject: Problem with multiple instances of a nib
- From: PCWiz <email@hidden>
- Date: Sun, 22 Nov 2009 15:06:47 -0700
Hi,
I have a separate XIB in which there is an NSPanel containing an image
view to set an image. When I call a method, it creates a new instance
of the controller for the nib, loads the nib, and then sets the image
of the image view via the controller object. Like this:
- (IBAction)newImagePanelForImage:(NSImage*)aImage
{
ImagePanelController *ctrl = [[[ImagePanelController alloc] init]
autorelease];
[NSBundle loadNibNamed:@"ImagePanel" owner:ctrl];
[ctrl setImage:aImage];
}
ImagePanelController is set as the File's Owner of the ImagePanel.nib
file. The controller itself is very simple:
//// Header
@interface ImagePanelController : NSObject {
IBOutlet NSImageView *mImageView;
}
- (void)setImage:(NSImage*)pic;
@end
//// Implementation
#import "ImagePanelController.h"
@implementation ImagePanelController
- (void)setImage:(NSURL*)pic
{
[mImageView setImage:pic];
}
@end
Most of this works just fine. When I call the method, a new panel pops
up and the image is displayed. The problem is, once I call the method
again to create another instance, the new panel pops up, and within
seconds any existing instances of the panel just vanish. I have no
idea what I'm doing wrong, I have GC turned on, could that be the
problem?
The weird part about this is that I did this code weeks ago and it
never had that problem, and without me changing anything directly
related with the nib, panel, controller, etc. this issue appeared.
Any help is appreciated
Thanks
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden