写道
The Dock tile plug-in must be placed inside the Contents/PlugIns directory of your application’s package. The plug-in is associated with the application by adding a NSDockTilePlugIn key to the application’s information property list. The value associated with this key is the name of the plug-in’s bundle, which must end with a .docktileplugin extension.
The principal class of the plug-in must implement the NSDockTilePlugIn protocol. The setDockTile: method is the only required method in this protocol. When the plug-in is loaded, an object of the principal class is instantiated, and its setDockTile: method is called. The call to this method provides an NSDockTile object to your plug-in. Your plug-in should retain the Dock tile object and perform any other initialization required by your plug-in. For example, if your plug-in receives information from a background-only application, it can register for a notification event sent by that other application.
Your Dock tile plug-in continues to run as long as your application’s tile is in the Dock, even if your application is actually running. Apple recommends that you update your Dock tile in either the application or the plug-in, but not both at the same time. Your application can continue to update the Dock tile inside your plug-in by having the plug-in receive notifications from your application. If both the application and the plug-in update the dock tile, the application takes precedence.
When your application is removed from the Dock, the setDockTile: method is called with a nil parameter. Your setDockTile: method should release the Dock tile object, clean up any resources your Dock Tile plug-in allocated, and exit.
Dock Plugin 主要做几个工作:
1,其中更改dock上application的图标。
写道
Dock tile icons can be customized using an NSView object. This is useful if your application needs to dynamically generate Dock tile icons at run time. To provide a custom view, you instantiate a new view object, retrieve the dock tile object from the application or window object, and set your view as its contentView.
When the Dock icon needs to be updated, you instruct the Dock to update the icon by calling the dock tile object’s display method.
[[NSApp dockTile] display];
2,更改badge:
写道
The dock tile object can overlay a short text message on top of the Dock icon. To change the badge label, you call the Dock tile’s setBadgeLabel: method.
[[myWindow dockTile] setBadgeLabel:@"42"];
3,定义自己的menu:
写道
Your class can optionally provide a dockMenu method to provide additional custom menu items. This method works similarly to the applicationDockMenu: method provided by the application delegate. Mac OS X calls your plug-in’s dockMenu method when the user requests the menu for your Dock tile.