本文介绍了的AppleEvent:如何调试`eventDidFail`?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我收到来自这个错误在控制台:

  11年5月9日17:00:09165 SIMBL代理:eventDidFail:tvea'错误:错误域= NSOSStatusErrorDomain code = -1708的操作无法完成。 (OSStatus误差-1708)(以下的AppleEvent不是由任何处理程序处理)的UserInfo = 0x400e485c0 {ErrorNumber = -1708} USERINFO:{
    ErrorNumber =-1708;
}

我想这调试;但我还没有真正使用的AppleEvent的工作还很多,我真的不知道如何跨preT这一点。

我觉得在SIMBL代理相关的code是这样的:

  AEEventID EVENTID ='负荷';//查找过程目标
将为pid_t PID = [[APPINFO objectForKey:@NSApplicationProcessIdentifier]的intValue];
SBApplication *应用= [SBApplication applicationWithProcessIdentifier:PID];
[应用setDelegate:个体经营];
如果(!APP){
    SIMBLLogNotice(@无法找到具有PID%d个应用程式,PID);
    返回;
}//力的AppleScript在应用程序初始化,通过获取字典
//初始化时,您需要等待事件的答复,否则,
//事件可能会被丢弃在地板上。这似乎只在10.5发生
//但应该不会伤害任何东西。
[应用setSendMode:kAEWaitReply | kAENeverInteract | kAEDontRecord];
ID initReply = [应用程序的SendEvent:kASAppleScriptSuite ID:kGetAEUT参数:0];//这里的回复是一些未知类型的 - 它不是一个Objective-C的对象
//尽可能接近我可以告诉,因为试图使用%@或获取其其打印
//类都导致应用程序段错误。该指针值似乎总是
//为0x10000的这是一个有点腥。它似乎并没有成为一个AEDesc结构
//无论是。
//因为我们正在等待答复,好像这个对象可能需要
//发布 - 但我不知道它是什么或如何将其释放。
//的NSLog(@initReply:%P'%64.64s',initReply,(字符*)initReply);//注入!
[应用setSendMode:kAENoReply | kAENeverInteract | kAEDontRecord];
ID injectReply = [应用程序的SendEvent:森达ID:事件ID参数:0];
如果(injectReply!=无){
    SIMBLLogNotice(@意外injectReply:%@,injectReply);
}


解决方案

eventDidFail 消息还来自SIMBL代理本身。正是这种code:

   - (无效)eventDidFail:(常量的AppleEvent *)事件withError:(NSError *)错误
{
    * NSDictionary的用户信息= [错误USERINFO]
    *的NSNumber = errorNumber [USERINFO objectForKey:@ErrorNumber];    //这个错误似乎豹更常见
    如果(errorNumber&安培;&安培; errorNumber的intValue] == errAEEventNotHandled){
        SIMBLLogDebug(@eventDidFail:'%4.4s'错误:%@用户信息:%@,(字符*)及(事件 - >的descriptorType),错误[错误USERINFO]);
    }
    其他{
        SIMBLLogNotice(@eventDidFail:'%4.4s'错误:%@用户信息:%@,(字符*)及(事件 - >的descriptorType),错误[错误USERINFO]);
    }
}

和错误消失,如果我注释掉code:

  [应用setSendMode:kAEWaitReply | kAENeverInteract | kAEDontRecord];
ID initReply = [应用程序的SendEvent:kASAppleScriptSuite ID:kGetAEUT参数:0];

I am getting this error from SIMBL in the console:

05.09.11 17:00:09,165 SIMBL Agent: eventDidFail:'tvea' error:Error Domain=NSOSStatusErrorDomain Code=-1708 "The operation couldn’t be completed. (OSStatus error -1708.)" (the AppleEvent was not handled by any handler ) UserInfo=0x400e485c0 {ErrorNumber=-1708} userInfo:{
    ErrorNumber = "-1708";
}

I am trying to debug this; but as I haven't really worked with AppleEvent that much yet, I'm not really sure how to interpret that.

I think the related code in the SIMBL Agent is this:

AEEventID eventID = 'load';

// Find the process to target
pid_t pid = [[appInfo objectForKey:@"NSApplicationProcessIdentifier"] intValue];
SBApplication* app = [SBApplication applicationWithProcessIdentifier:pid];
[app setDelegate:self];
if (!app) {
    SIMBLLogNotice(@"Can't find app with pid %d", pid);
    return;
}

// Force AppleScript to initialize in the app, by getting the dictionary
// When initializing, you need to wait for the event reply, otherwise the
// event might get dropped on the floor. This is only seems to happen in 10.5
// but it shouldn't harm anything.
[app setSendMode:kAEWaitReply | kAENeverInteract | kAEDontRecord];
id initReply = [app sendEvent:kASAppleScriptSuite id:kGetAEUT parameters:0];

// the reply here is of some unknown type - it is not an Objective-C object
// as near as I can tell because trying to print it using "%@" or getting its
// class both cause the application to segfault. The pointer value always seems
// to be 0x10000 which is a bit fishy. It does not seem to be an AEDesc struct
// either.
// since we are waiting for a reply, it seems like this object might need to
// be released - but i don't know what it is or how to release it.
// NSLog(@"initReply: %p '%64.64s'", initReply, (char*)initReply);

// Inject!
[app setSendMode:kAENoReply | kAENeverInteract | kAEDontRecord];
id injectReply = [app sendEvent:'SIMe' id:eventID parameters:0];
if (injectReply != nil) {
    SIMBLLogNotice(@"unexpected injectReply: %@", injectReply);
}
解决方案

The eventDidFail message also comes from the SIMBL Agent itself. It is this code:

- (void) eventDidFail:(const AppleEvent*)event withError:(NSError*)error
{
    NSDictionary* userInfo = [error userInfo];
    NSNumber* errorNumber = [userInfo objectForKey:@"ErrorNumber"];

    // this error seems more common on Leopard
    if (errorNumber && [errorNumber intValue] == errAEEventNotHandled) {
        SIMBLLogDebug(@"eventDidFail:'%4.4s' error:%@ userInfo:%@", (char*)&(event->descriptorType), error, [error userInfo]);
    }
    else {
        SIMBLLogNotice(@"eventDidFail:'%4.4s' error:%@ userInfo:%@", (char*)&(event->descriptorType), error, [error userInfo]);
    }
}

And the error disappears if I comment out this code:

[app setSendMode:kAEWaitReply | kAENeverInteract | kAEDontRecord];
id initReply = [app sendEvent:kASAppleScriptSuite id:kGetAEUT parameters:0];

这篇关于的AppleEvent:如何调试`eventDidFail`?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-03 09:13