How to develop status bar app in OS X Yosemite?

2019-03-20 02:00发布

I've been trying to develop a status bar app for Yosemite, which is my first OS X app, but when I searched for the document, the NSStatusItem documentation says that almost all of the properties and methods there (e.g. .title, .highlightMode, and .image) are deprecated in OS X 10.10.

So I wonder how I can create a status bar app for Yosemite. I found those documentations from Dash, but it's weird that Apple's documentation doesn't make it deprecated yet. But I know they are usually slow to update the documentation, though I wonder then how and where Dash got those seemingly updated information...

So which is the correct? And if it is deprecated, where can I find the Yosemite-style status bar development resources?

I use Xcode 6.1 Beta and Swift.

1条回答
SAY GOODBYE
2楼-- · 2019-03-20 02:27

In 10.10, NSStatusItem has a new button property which returns an instance of a new class, NSStatusBarButton inheriting from NSButton. This is what should be used instead of setting a custom view on the status item. The deprecated methods of NSStatusItem just forward on to the corresponding method of the button.

See the header files (NSStatusItem.h and NSStatusBarButton.h) for the most current and accurate documentation. The prerelease class references seem to be incomplete. There's some brief, indirect mentions of these changes in the 10.10 AppKit release notes.

查看更多
登录 后发表回答