What's the meaning of owner when using loadNibNamed?

Viewed 1180

Apple Doc says One of the most important objects in a nib file is the File’s Owner object , but it seems that's the File's owner in nib file , not the one set by LoadNibName method. I wonder what's the difference between them?

Here is an example:

I customize an alertView from xib and offer a static class method like this:

+(CustomAlert *)sharedAlert{
    CustomAlert *alert = [[[NSBundle mainBundle] loadNibNamed:@"CustomAlert" owner:nil options:nil]lastObject];
    return alert;
}

and I have a method to show alert on view

- (void)showInView:(UIView *)view{
    [view addSubview:self];
}

and in my viewController:

- (IBAction)buttonPressed:(id)sender{
    CustomAlert *alert = [CustomAlert sharedAlert];
    [alert showInView:self.view];
}

it works well in my situation,so is it necessary to set the owner in [[[NSBundle mainBundle] loadNibNamed: owner: options:?

1 Answers
Related