Dustin
Dustin

Reputation: 744

Menu bar menu entries get disabled after period of time

I have an app that resides in the Mac's menu bar with menu entries for controlling the app. After the app has been running for awhile without interaction all of the menu entries will get disabled. The only way to "fix" the menu is to start the app again (while it is already running and without quitting the app) and the menu entries will become enabled again.

Is the cause of my issue because I've declared the IBOutlet for this menu weak and it should be strong? Or is there another reason this might happen?

Upvotes: 3

Views: 217

Answers (3)

Rob Keniger
Rob Keniger

Reputation: 46020

If you are using ARC on Mac OS X then you MUST use a strong reference when you create outlets to top-level objects in a nib. If you don't, the objects will be released.

On iOS things are different because of the way UIViewController works and you should use a weak reference instead.

Upvotes: 1

maranas
maranas

Reputation: 1416

NSMenuS do automatic validation of the NSMenuItems. If any of the item targets are nil, or if any target does not respond to the intended message, it is automatically disabled. To override this behavior, implenet validateMenuItem: in your NSMenu subclass. Be careful, though, as usually when NSMenuItems are disabled, this often meanse the target of the message has been released, or is not available anymore.

Upvotes: 1

David Smith
David Smith

Reputation: 426

I am the author of a similar app, that sits in the menu bar and I've been able to keep it running for long stretches without ever seeing the issue you are describing. While I don't know exactly what is causing your problem I can say that I use a strong IBOutlet reference for my NSMenu which seems to work just fine.

Upvotes: 1

Related Questions