Commented out the aliasdata stuff that doesn't work
[ITFoundation.git] / ITAppleEventTools.m
index 217a1d1..9eaacb1 100755 (executable)
@@ -19,7 +19,9 @@ NSAppleEventDescriptor *ITSendAEWithString(NSString *sendString, FourCharCode ev
     
     AppleEvent sendEvent, replyEvent;
     NSAppleEventDescriptor *send, *recv;
-    AEDesc nthDesc;
+    AEDesc resultDesc;
+    DescType resultType;
+    Size resultSize;
     
     AEBuildError buildError;
     OSStatus berr,err;
@@ -39,10 +41,14 @@ NSAppleEventDescriptor *ITSendAEWithString(NSString *sendString, FourCharCode ev
     
     err = AESend(&sendEvent, &replyEvent, kAEWaitReply, kAENormalPriority, kNoTimeOut, NULL, NULL);
     
-    err = AEGetNthDesc(&replyEvent, 1, typeWildCard, nil, &nthDesc);
-    if (!err) ITDebugLog(@"Error getting Nth desc.");
+    err = AESizeOfParam(&replyEvent, keyDirectObject, &resultType, &resultSize);
+    if (resultSize == 0 || err != 0) {
+        return nil;
+    }
+    
+    AEGetParamDesc(&replyEvent, keyDirectObject, resultType, &resultDesc);
     
-    recv = [[[NSAppleEventDescriptor alloc] initWithAEDescNoCopy:&nthDesc] autorelease];
+    recv = [[[NSAppleEventDescriptor alloc] initWithAEDescNoCopy:&resultDesc] autorelease];
     if (!err) [recv logDesc];
     
     if (err) {