Question on File's owner

Discussion in 'Mac Programming' started by MacRohde, Feb 2, 2009.

  1. macrumors regular

    MacRohde

    Joined:
    Jun 1, 2004
    Location:
    Copenhagen, Denmark
    #1
    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?
     
  2. thread starter macrumors regular

    MacRohde

    Joined:
    Jun 1, 2004
    Location:
    Copenhagen, Denmark
    #2
    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
     

Share This Page