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

MacRohde

macrumors regular
Original poster
Jun 1, 2004
164
0
Copenhagen, Denmark
I'm not sure if I totally understand the concept of File's owner. So I have a question about this.

As I understand it, the File's owner is the link from a nib to the outside.
And one way is to set the controller of the nib to the file's owner. Is that correct?

For example, if I have a menu item that opens a dialog from another nib, then I can respond to a click on that menu item like so in order to show a dialog for converting numbers between different base systems:

Code:
-(IBAction) showConvertNumberToBaseDialog:(id)sender {		
	convertNumberToBaseController = [[ConvertNumberToBaseController alloc] init];
	
	if (![NSBundle loadNibNamed:@"ConvertNumberToBase" 
						  owner:convertNumberToBaseController])
	{
		NSLog(@"Error loading Nib for ConvertToBase dialog!");
	}	
}

So here an instance of the ConvertNumberToBaseController is set as the file's owner of the corresponding ConvertNumberToBase nib.

Would that be correct?
 

MacRohde

macrumors regular
Original poster
Jun 1, 2004
164
0
Copenhagen, Denmark
Ok., so after some research I can answer my own question. I can do what I has done - which is to use a single controller as both the coordinating controller and the mediating controller.

Usually it is best not to combine both roles into a single controller, as I have done, but for some situations it is suitable.

More can be read here:

The Model-View-Controller Design Pattern
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.