That show up on menu bar
It’s like this question: How to create a background-running Cocoa application?
However he ask how to make something that doesn’t show up on menu bar. Well I want things to show up on menu bar.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The key things you want to do after starting a new Cocoa application in Xcode:
1) Give one of your classes an
NSStatusItem@propertyand anIBOutlet NSMenu@propertyand initialize them once the application has started in your
AppDelegate‘sawakeFromNib(of course, it doesn’t have to be theAppDelegatethat controls the status item; you could use another class):2) In your MainMenu.xib, make an
NSMenuand wire it up to yourAppDelegate‘sNSMenuIBOutlet. This will be the menu that shows up when you click on your status item, so add any additional items you want, makeIBActionsfor them, and wire them up.3) Also in your MainMenu.xib, delete the Window object in MainMenu.xib because you don’t need a main window to show up when you start the application.
4) In your info.plist, add the key “Application is agent (UIElement)” and set its value to YES. This gets rid of the dock icon.
The tutorial that GravityScore linked to covers the same material as above. If after reading the above you’re not sure how you would set up actions for the menu items, or want to know how to dynamically add menu items, this other tutorial might be helpful.
And of course, see the NSStatusItem Class Reference for how to customize the status item’s appearence.