In my main nib (nib1), I have a button that activates another nib (nib2) using the piece of code below.
The way that I currently pass values to nib2 and obtain from nib2 is by creating class methods in nib1. But one of my goal of this exercise project is that I need to design nib2 such that I will be able to re-use nib2 at another later project. That implies nib2 should not know anything about nib1’s class. So that when I re-use nib2 at a later time, I do not need to modify its code (to call nib1’class methods.)
I was thinking about creating class methods in nib2’s class. But then how will I be able to call the method before nib2 is active?
Is my approach right? any comments?
NSWindowController *iQWController = [[NSWindowController alloc] initWithWindowNibName:@"iQueryWindow"];
[iQWController showWindow:sender];
For this example I assume you have class definitions nib1.h/nib1.m/nib1.xib & nib2.h/nib2.m/nib2.xib
You should create properties in nib2 for getting the data into nib 2.
To get data from nib 2 back to nib 1, you should define a delegate protocol, have nib 1 implement it and set it as nib 2’s delegate.
nib2.h would look something like:
in Nib1.h you would have:
in Nib1.m
Then you would implement myMethod in Nib1.m. When you want to call it in Nib2.m it would look like