HeaderView assignment


I’m confused about the following code and how it actually works:
(its location 5452 in the digital edition- for those with the print editing its just after figure 10.6 -the color picker)

-(UIView *) headerView
    // if we havent loaded the headerview yet...
        //load the HeaderView.xib
        [[NSBundle mainBundle] loadNibNamed:@"HeaderView" owner:self options:nil];

return headerView;

I’m a bit confused about the above code… shouldnt the line of code

[[NSBundle mainBundle]loadNibNamed:@“HeaderView” owner:self options:nil];

actually be

headerView = [[NSBundle mainBundle] loadNibNamed:@“HeaderView” owner:self options:nil];

Thanks in advance.


I don’t think so, headerView is a pointer to a UIView.
The return value of [[NSBundle mainBundle] loadNibNamed:@“HeaderView” owner:self options:nil]; is a pointer to a NSArray.
Just above the colorpicker, in the book, you have a image that shows you to link the xib view to the headerView in the Files’s Owner.


Thanks for your input Slash. I missed the diagram connection part. It makes sense now :slight_smile: