如何制作 NSMenu 最近列表

发布于 2024-08-23 23:40:48 字数 255 浏览 4 评论 0原文

我正在为某人开发一个小型 URL 缩短应用程序,我需要一个类似于 Droplr 的列表,其中包含所有最近缩短的 URL。该列表应该是主菜单的子菜单,它附加到 NSStatusItem。

我需要让该列表在每次缩短 URL 时添加一个项目,并且我希望在单击时显示一个带有其中链接的通知。该列表不应包含超过 10 个最近的 URL。

我还需要有一种方法来存储列表,以便在应用程序再次启动时它会出现。我认为使用 Core Data 不是一个好主意,但我不确定应该使用什么。

I'm working on a small URL shortening application for someone, and I need to have a list, similar to that of Droplr's, that has all of the recently shortened URLs. The list should be a submenu of the main menu, which is attached to an NSStatusItem.

I need to have that list add an item each time a URL is shortened, and I'd like to have a notification come up with the link in it when clicked. The list should have no more than about ten recent URLs.

I also need to have a way to store the list so that it will come up when the app is started again. I don't think it would be a good idea to use Core Data for it, but I'm not sure of what I should use.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

失与倦" 2024-08-30 23:40:48

每次缩短 URL 时,我都需要让该列表添加一个项目,...

您绝对应该 这样做

…我希望在单击时显示一条通知,其中包含链接。

只要通知显示“已将 [短 URL] 复制到剪贴板”,否则该通知就没有用。

列表中最近的 URL 不应超过 10 个。

听起来不错。您可以在“首选项”面板中进行配置。

我还需要一种方法来存储该列表,以便在应用程序再次启动时它会出现。

我同意。

我认为使用 Core Data 不是一个好主意,但我不确定应该使用什么。

核心数据可能有点大材小用,但它可以发挥作用。另一种方法是将其存储在 plist 文件中,使用 NSPropertyListSerialization 将(完全自定义)模型对象数组转换为 plist 数据。

I need to have that list add an item each time a URL is shortened, …

You definitely should do that.

… and I'd like to have a notification come up with the link in it when clicked.

As long as the notification says “Copied [short URL] to the clipboard”, since the notification wouldn't be useful otherwise.

The list should have no more than about ten recent URLs.

Sounds good. You could make this configurable in a Preferences panel.

I also need to have a way to store the list so that it will come up when the app is started again.

I agree.

I don't think it would be a good idea to use Core Data for it, but I'm not sure of what I should use.

Core Data may be overkill, but it could work. The other way would be to store it in a plist file, using NSPropertyListSerialization to convert your array of (completely custom) model objects to plist data.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文