多个仪表板小部件实例无法在小部件更新后继续存在。 有什么办法可以防止这种情况吗?

发布于 2024-07-24 08:59:12 字数 843 浏览 7 评论 0原文

我编写了一个 Mac OS X 仪表板来展示您自己和其他人的 StackOverflow 天赋。

我的问题是,每当我将该小部件更新到新版本时,所有以前的实例都会被删除,并在仪表板上创建一个新实例。 因此,如果您之前遵循了 4 个人的天赋,则必须重新创建小部件并再次输入他们的用户 ID。 :(

有没有办法在更新小部件时保留所有正在运行的实例?

检查首选项文件,我发现部署新版本的小部件后会创建一个新实例。这是设计使然吗? all< /strong> 小部件的工作方式有可能是这样吗?如果是这样,可以通过某种方式手动规避吗?

您可以在 http://widget.huxhorn.de

我已更改了 remove() 中的代码,以设置首选项为正确的值,而不是 < em>null 如下所示 - 但这也没有帮助。
我有什么错?? 帮助! 我被困住了!


我的小部件的另一个问题已修复:
我不小心打电话

widget.preferenceForKey(null, dashcode.createInstancePreferenceKey(userIdPrefKey));

给了,

widget.preferenceForKey(dashcode.createInstancePreferenceKey(userIdPrefKey));

但现在已修复(尚未发布)。

I've written a Mac OS X Dashboard to show the StackOverflow flair of yourself and other people.

My problem is that whenever I update that widget to a new version, all previous instances are removed and a single new instance is created on the Dashboard. So if you previously followed the flair of 4 people you'll have to recreate the widgets and enter their user-IDs again. :(

Is there any way to keep all running instances while updating a widget?

Checking the preferences file, I see that a new instance is created after a new version of the widget is deployed. Is this by design? Does all widgets work like this, by any chance?? If so, can this be manually circumvented somehow?

You can find the widget in question, including the project files, at http://widget.huxhorn.de

I've changed the code in remove() to set the preferences to the correct values instead of null as suggested below - but this doesn't help, either.
What's my mistake?? Help! I'm stuck!


The other problem of my widget has been fixed:
I accidentally called

widget.preferenceForKey(null, dashcode.createInstancePreferenceKey(userIdPrefKey));

instead of

widget.preferenceForKey(dashcode.createInstancePreferenceKey(userIdPrefKey));

but this is now fixed (not yet released).

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

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

发布评论

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

评论(2

梦言归人 2024-07-31 08:59:12

我知道这个接管安装过程的工具:http://junecloud。 com/software/mac/smart-widget-installer.html

替代文字
(来源:junecloud.com

I know about this tool that takes over the install process: http://junecloud.com/software/mac/smart-widget-installer.html

alt text
(source: junecloud.com)

白日梦 2024-07-31 08:59:12

我认为您对 setPreferenceForKey 和preferenceForKey 的调用看起来很奇怪。 这个 null 从哪里来。 它们不应该看起来像

widget.preferenceForKey(dashcode.createInstancePreferenceKey(userIdPrefKey))
widget.setPreferenceForKey(value, dashcode.createInstancePreferenceKey(userIdPrefKey));

remove() 中带有 null 的语法会

widget.setPreferenceForKey(null, dashcode.createInstancePreferenceKey(userIdPrefKey))

删除首选项吗? 我想这可以解释你的情况。 更新时,remove() 会被调用,因此在重新启动小部件时,首选项就会消失。


我想只有一种方法可以在更新期间保留您的偏好。 创建一个首选项键而不依赖dashboard.createInstancePreferenceKey,而是认为自己有一个唯一的键值。

在此preferenceKey中,您可以使用不断增长的(例如逗号分隔)列表保存所有曾经输入的用户ID(通过任何实例)。 当打开小部件实例时, widget.preferenceForKey(dashcode.createInstancePreferenceKey(userIdPrefKey)) 尚未设置,您可以通过给用户一个选择或这样的东西来让用户选择其中

一个只是想也许更新过程足够好,可以将首选项迁移到新版本。 即使您不删除首选项,我认为 widget.identifier (createInstancePreferenceKey) 也会发生变化,因此您无法访问“旧”设置。

I think your calls to setPreferenceForKey and preferenceForKey look strange. Where does that null come from. Shouldn't they look like

widget.preferenceForKey(dashcode.createInstancePreferenceKey(userIdPrefKey))
widget.setPreferenceForKey(value, dashcode.createInstancePreferenceKey(userIdPrefKey));

Does the syntax with null

widget.setPreferenceForKey(null, dashcode.createInstancePreferenceKey(userIdPrefKey))

in remove() delete the preference? That would explain you situation I guess. On Update the remove() gets surley called and thus on restart of the widget the preferences are gone.


I guess there is only one way to keep your preferences during an update. Create one preferencekey without relying on dashboard.createInstancePreferenceKey but instead think yourself of a unique key value.

In this preferenceKey you could then save all ever entered userids (by any instance) with a growing (say comma seperated) list. When a widget instance is opened an the widget.preferenceForKey(dashcode.createInstancePreferenceKey(userIdPrefKey)) isn't already set you could let the user choose one of those by giving him a select or such a thing

I was just thinking maybe the update process is nice enough to migrate the preferences to the new verison. Even when you don't remove the preferences I think the widget.identifier (createInstancePreferenceKey) will have changed an thus you can't access the "old" settings.

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