为什么 NSWorkspace 的 openURL 无法打开多个 URL?
我有一个菜单项的操作,该操作应该根据“lyricLink”属性的值打开一个 URL。它将在第一次工作(以及“lyricLink”值相同的所有后续时间)。但是,如果“lyricLink”的值发生变化并且再次调用该操作,它将不会打开新链接。有什么想法吗?
- (void)openLyricLink:(id)sender
{
[[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:[self lyricLink]]];
}
I have an action for a menu item that is supposed to open a URL base on the value of the 'lyricLink' property. It will work the first time (and all subsequent times where the value of 'lyricLink' is the same). But if the value of 'lyricLink' changes and the action is called again, it won't open the new link. Any ideas?
- (void)openLyricLink:(id)sender
{
[[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:[self lyricLink]]];
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为首先要检查的是 [self lyricLink] 在后续调用中返回有效的字符串。我想添加:
在调用 NSWorkspace 之前查看 lyricLink 是否是有效的 URL。
I think the first thing to check would be that [self lyricLink] is returning a valid string on the subsequent calls. I would add:
before calling NSWorkspace to see if lyricLink is a valid URL.