Commented out the aliasdata stuff that doesn't work
[ITFoundation.git] / ITAppleEventTools.m
index e4bd45a..9eaacb1 100755 (executable)
@@ -19,6 +19,9 @@ NSAppleEventDescriptor *ITSendAEWithString(NSString *sendString, FourCharCode ev
     
     AppleEvent sendEvent, replyEvent;
     NSAppleEventDescriptor *send, *recv;
+    AEDesc resultDesc;
+    DescType resultType;
+    Size resultSize;
     
     AEBuildError buildError;
     OSStatus berr,err;
@@ -37,7 +40,15 @@ NSAppleEventDescriptor *ITSendAEWithString(NSString *sendString, FourCharCode ev
     }
     
     err = AESend(&sendEvent, &replyEvent, kAEWaitReply, kAENormalPriority, kNoTimeOut, NULL, NULL);
-    recv = [[[NSAppleEventDescriptor alloc] initWithAEDescNoCopy:&replyEvent] autorelease];
+    
+    err = AESizeOfParam(&replyEvent, keyDirectObject, &resultType, &resultSize);
+    if (resultSize == 0 || err != 0) {
+        return nil;
+    }
+    
+    AEGetParamDesc(&replyEvent, keyDirectObject, resultType, &resultDesc);
+    
+    recv = [[[NSAppleEventDescriptor alloc] initWithAEDescNoCopy:&resultDesc] autorelease];
     if (!err) [recv logDesc];
     
     if (err) {