如何制作 NSMenu 最近列表
我正在为某人开发一个小型 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您绝对应该 这样做。
只要通知显示“已将 [短 URL] 复制到剪贴板”,否则该通知就没有用。
听起来不错。您可以在“首选项”面板中进行配置。
我同意。
核心数据可能有点大材小用,但它可以发挥作用。另一种方法是将其存储在 plist 文件中,使用 NSPropertyListSerialization 将(完全自定义)模型对象数组转换为 plist 数据。
You definitely should do that.
As long as the notification says “Copied [short URL] to the clipboard”, since the notification wouldn't be useful otherwise.
Sounds good. You could make this configurable in a Preferences panel.
I agree.
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.