Re: Unable to launch about panel for the 2nd time
Re: Unable to launch about panel for the 2nd time
- Subject: Re: Unable to launch about panel for the 2nd time
- From: Jason Coco <email@hidden>
- Date: Tue, 23 Sep 2008 23:07:51 -0400
On Sep 23, 2008, at 02:58 , Arun wrote:
Hi All,
I am a newbie to cocoa programming.
I have written a small program in which i will be loading a Custom
About
panel from another nib.
This launching of the panel works well only for the first time.
If i close the panel and try to launch for the 2nd time, it is
unable to
show the panel.
Can anyone let me know what is wrong in the code?
Attaching the code along with this mail.
Thanks in advance..!!!
Hi Arun,
The problem is that you're AboutPanel nib is wired-up a bit wrong.
Since you're loading the instance yourself, you don't want to create
the AboutPanelController object *inside* the nib. This is what the
File's Owner object is for. To correct your issue keeping (mostly) the
same code as in your small example project, make these changes:
In AbouPanel.nib:
1) Delete the instance of AboutPanelController
2) Select File's Owner and open the inspector; under the Identity
panel, change the Class to AboutPanelController
3) Wire your File's Owner mPanelToDisplay outlet to the panel in the nib
4) (optional since you don't do any delegate methods at the moment)
wire your panel's delegate outlet to File's Owner
5) Save (and optionally quit IB)
In AboutPanelController.mm:
1) In the method implementation for sharedInstance, change line 20 to
the following line (change marked in bold):
if (YES == [NSBundle loadNibNamed:@"AbouPanel.nib"
owner:sharedInstance];
2) save and rebuild -- this should now work as expected
In this case, you want your sharedInstance variable to actually be the
file's owner so that it can receive messages meant for the panel in
the nib. You don't want
the class itself to be the file's owner since you're actually creating
an instance of the class here.
HTH, Jason Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
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