• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Passing NSAppleEventDescriptors for application-specific objects
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Passing NSAppleEventDescriptors for application-specific objects


  • Subject: Passing NSAppleEventDescriptors for application-specific objects
  • From: Derrick Bass <email@hidden>
  • Date: Tue, 6 Dec 2005 05:31:09 -0600

I have an applescript with a couple of handlers. One returns an iTunes track and another takes an iTunes track as an argument. But I'm having trouble getting the descriptor returned from the first handler to be accepted by the second. Also, this is not iTunes specific in any way. I've tried with a couple of other applications. On the other hand, if the first handler returns something like a string, everything works fine.

I think I somehow need to explain to the second handler that this object belongs to iTunes, but I don't know how to do that.

I've tried both Ken Ferry's library and Nathan Day's library; I'm pretty sure the problem isn't in the libraries. Here's the code:
In subroutines.applescript:
on getOneTrack()
tell application "iTunes"
return item 1 of selection
end tell
end getOneTrack

on doSomethingWithObject(object)
-- in the real program we would actually do something
end doSomethingWithObject

In my Cocoa code (this code uses Ken Ferry's additions to NSAppleScript; the script was set up earlier in the program):
id ot = [script executeHandler:@"getOneTrack"];
NSLog(@"ot %@", ot);
[script executeHandler:@"doSomethingWithObject" withParameter:ot];

The NSLog prints: <NSAppleEventDescriptor: 'obj '{ 'form':'ID ', 'want':'cFlT', 'seld':5157, 'from':'obj '{ 'form':'ID ', 'want':'cLiP', 'seld':2614, 'from':'obj '{ 'form':'ID ', 'want':'cSrc', 'seld':42, 'from':''null''() } } }.
The executeHandler method returns the error: Can't get «class cFlT» id 5157 of «class cLiP» id 2614 of «class cSrc» id 42.

I notice that the descriptor doesn't include any reference to "iTunes", so presumably that is the problem. For some reason it doesn't know that the object comes from iTunes. So, is there a way to add that information to the NSAppleEventDescriptor? Or perhaps a way to either modify the script so that the returned value also contains a reference to the application? (I tried enclosing the "doSomethingWithObject" routine with "using terms from application "iTunes", but that had no effect.)

Derrick

PS: This question came up a few years ago on both cocoa-dev and applescript-studio and there was no answer.

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden
  • Prev by Date: NSTableHeaderCell Woes...
  • Next by Date: tableview shouldSelectRow called twice ?
  • Previous by thread: Re: NSTableHeaderCell Woes...
  • Next by thread: tableview shouldSelectRow called twice ?
  • Index(es):
    • Date
    • Thread