cocoa - How do you make a Menu Bar Item display how many rows there are in a table? -
A core data table to me and I would like to display how many rows in the table menu bar item. I already have the menu bar created before using this code:
- (minus) applicationDidFinishLaunching: (NSNotification *) aNotification {NSStatusItem * statusItem = [[[NSStatusBar systemStatusBar] statusItemWithLength: NSVariableStatusItemLength] Retaining]; // Create new status item example [Status item set Highlight mode: Yes]; // It does something, I confirm it. [Status item settl: [nsstating string with format: @ "% c", 0xff50]]; // It labels you can use setImage instead of using the icon. The result of the current code will be in an item named "P" [Status item set enabled: Yes]; // Self explanatory [Status item set menu: The menu]; [Status set settip: @ "Tooltape hi ammiss?"]; // Optional, just for kick}} Do I need to add menu bar item to show how many rows are in the table?
If you do not need to be updated live, you can try this approach,:
1) set theMenu's representative:
[Set the menu to Deliigate: Self]; 2) and representatives methode apply:
- (minus) menuWillOpen: (NSMenu *) Menu {NSUInteger count = [self.tableView numberOfRows]; [[Menu Aitmaetindaks: 0] Settitl [Ansstiing Stringvet format: @ "% d rows", count]]; } will refresh the code menu item opens every time the user menu if you use Kevio to see you array controller if you want to refresh it every time tables, Will happen. If you want to display the count in the title of the statSAT, then you will also need to use KVO.
Comments
Post a Comment