NSMenu delegate did not call to fill out

I have a controller object that owns NSMenu and is a menu delegate, in the interests of a lazy population.

However, neither numberOfItemsInMenu: nor menuNeedsUpdate: ever called, so the menu remains empty.

I have confirmed that:

  • The controller object is not freed. (The controller, in turn, owns the menu.)
  • He has a menu.
  • There is a delegate in the menu, and this is the controller.

If I implement menuWillOpen: which is called, but you should not populate the menu there .

I tried to send the update message to the menu, and this did not affect. The delegate was left without a call, and the menu remained empty.

In case it is relevant: this menu is absent in the main menu; It is used elsewhere.

Why doesn't the menu ask its delegate to fill it in? Is there something I missed, or is it just broken?

+6
source share
1 answer

You might need a strong delegate reference. Try changing the variable declaration from your method and enter a member variable of the class. look at this answer: fooobar.com/questions/958713 / ...

0
source

Source: https://habr.com/ru/post/958711/


All Articles