【发布时间】:2014-06-27 00:37:34
【问题描述】:
我在 Mac 可可应用中实现了自定义 URL 方案。它有效,但我遇到了几个问题。
1) 我应该将此代码放在基于文档的应用程序的什么位置来处理 URL 事件?我在我的-windowControllerDidLoadNib: 中有它,但如果由于尚未设置文档而关闭应用程序,它就不起作用。
NSAppleEventManager *appleEventManager = [NSAppleEventManager sharedAppleEventManager];
[appleEventManager setEventHandler:self andSelector:@selector(handleGetURLEvent:withReplyEvent:) forEventClass:kInternetEventClass andEventID:kAEGetURL];
2) 如何将解析后的数据从 URL 发送到新文档?我正在使用我的 -handleGetURLEvent:withReplyEvent: 方法创建新文档,就像这样。
[[NSDocumentController sharedDocumentController] newDocument:nil];
【问题讨论】:
标签: objective-c macos cocoa url-scheme