Question

I've looked through the related questions and have examined Apple's sample project but these examples do almost everything programmatically. I would prefer to do as much as possible in IB.

My question is: what is the general procedure to accomplish this?

  1. Create a new xib file to hold an NSView subclass with the various embedded UI elements.
  2. Create the NSView subclass in code.
  3. As I add items to my menu (which occurs dynamically) I'd create the NSMenuItem and then call the instance's setView: method.

I'm confused about setting FilesOwner in IB (is my custom NSView subclass FilesOwner in this case)?

Any clarification would be much appreciated.

Was it helpful?

Solution

I would create a new xib, if the custom view is more complex. If it is a very simple view, you can create it in code.

Regarding File's owner and structure, I would use a NSViewControllerif the custom menu item view has its own xib file. Then instantiate this view controller in code and assign its view to the NSMenuItem. That way you can handle organizational stuff through the controller and keep along the MVC paradigm.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top