是否有可能知道通过AppleScript的活动得到GURL电话引荐? [英] Is it possible to know referrer for GURL call received via AppleScript event?
问题描述
我有我的Cocoa应用程序相关的协议处理程序。
I have a protocol handler associated with my Cocoa application.
[[NSAppleEventManager sharedAppleEventManager]
setEventHandler:self
andSelector:@selector(getUrl:withReplyEvent:)
forEventClass:kInternetEventClass andEventID:kAEGetURL];
...
- (void)getUrl:(NSAppleEventDescriptor *)event withReplyEvent:(NSAppleEventDescriptor *)replyEvent
{
#ifdef DEBUG
NSLog(@"%s: %@",__PRETTY_FUNCTION__,event);
#endif
NSURL *url = [NSURL URLWithString:[[event paramDescriptorForKeyword:keyDirectObject] stringValue]];
...
}
是谁引荐? (如果从本地机器叫我认为这可能是不确定的,但如果我叫
从网站这个协议......我想知道从哪个收到请求域。
Who is referrer? (if it called from local machine I think it can be undefined, but if I call this protocol from a Web site... I would like to know domain from which the request is received.
是否有可能呢?
有没有解决另一个方式来解决这个任务?
Is there solution to solve this task by another way?
推荐答案
来源:
<一href=\"http://www.cocoabuilder.com/archive/cocoa/125741-finding-the-sender-of-an-appleevent-in-cocoa-app-on-10-2-8-or-greater.html\" rel=\"nofollow\">http://www.cocoabuilder.com/archive/cocoa/125741-finding-the-sender-of-an-appleevent-in-cocoa-app-on-10-2-8-or-greater.html
NSAppleEventDescriptor *addrDesc = [event
attributeDescriptorForKeyword:keyAddressAttr];
NSData *psnData = [[addrDesc
coerceToDescriptorType:typeProcessSerialNumber] data];
if (psnData)
{
ProcessSerialNumber psn = *(ProcessSerialNumber *) [psnData bytes];
...
}
这篇关于是否有可能知道通过AppleScript的活动得到GURL电话引荐?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!