Just a coder
Just a coder

Reputation: 16730

Need some clarity on NIB file objects

I have a MainViewController class set up with a simple nib. On the nib i have only these few objects. I have set the popoverViewController's file owner to the MainViewController. enter image description here

I have set the popoverViewController class to my PVController class so that i can put buttons/code/labels etc. enter image description here

The Popover works fine, but somethings are is puzzling me which i need help to understand.

  1. That newly created PVController class has an init method that is never called when the popover is loaded. Yet the popover still works? If i put break points in the -(IBAction) buttons however, they are called when i click the buttons for them. But the init is never called. If I however, go to the file owner (MainViewController) and do --> PVController *pv = [[PVController alloc] init], only then it is called. So my first question is, will there be any problems if i do not alloc/init an IBOutlet in FileOwner, since it seems to work without it (altho the PVController's init method isnt called)? And why isnt it called?
  2. If i did decide to create that IBOutlet in FileOwner for the Popover View Controller's referencing outlet, do i make it as strong? or weak? My noobish instincts tells me weak because it is already owned by the NIB, but when i put weak, I get a yellow error next to the init of the IBOutlet saying message

enter image description here

Upvotes: 0

Views: 166

Answers (1)

Anoop Vaidya
Anoop Vaidya

Reputation: 46543

So my first question is, will there be any problems if i do not alloc/init an IBOutlet in FileOwner

NO, there will not be any problem. Infact IBOutlets are never alloc+init manually.

Upvotes: 1

Related Questions