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

ruhi

macrumors member
Original poster
Jun 17, 2009
70
0
Hello,

i have a button on my MainMenu.xib window. Clicking over it causes another nib(mainWindow.xib) to load which has some text written on it.

Is there any way through which i can check whether or not any previous instance of nib is already loaded so that clicking over the button again will not load mainWindow.xib until first instance of mainWindow.xib is unloaded.

Thanks,
Ruhi.
 

kainjow

Moderator emeritus
Jun 15, 2000
7,958
7
Wrap your nib code into an NSWindowController (which handles loading the nib). Then you can store a reference to that controller and only load it once. For example:
Code:
// .h
MyWindowController *winController;

// .m
if (!winController)
    winController = [[MyWindowController alloc] init];
[winController showWindow:nil];
 

robbieduncan

Moderator emeritus
Jul 24, 2002
25,611
893
Harrogate
Wrap your nib code into an NSWindowController (which handles loading the nib). Then you can store a reference to that controller and only load it once. For example:
Code:
// .h
MyWindowController *winController;

// .m
if (!winController)
    winController = [[MyWindowController alloc] init];
[winController showWindow:nil];

You could even make the window controller a singleton object to ensure you only ever load it once, even if you try and create another window controller instance (say if the window is an inspector that there can only ever be one of).
 

ruhi

macrumors member
Original poster
Jun 17, 2009
70
0
Multiple Nib Instance

Thanks a lot.

It working fine now.

Thanks,
ruhi
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.