On 30 Aug 2017, at 16:41, Shane Stanley <sstanley@...> wrote:
On 30 Aug 2017, at 7:15 pm, Gerriet M. Denkmann <g@...> wrote:
… How to get here?
Your code answers that question. What you don’t explain is what you want to do, presumably with the descriptor, when you get there.
Sorry, if my explanation was not too clear.
This is the code:
- (void)applicationWillFinishLaunching:(NSNotification *)aNotification
{
NSAppleEventManager *sharedAppleEventManager = [ NSAppleEventManager sharedAppleEventManager ];
[ sharedAppleEventManager setEventHandler: self
andSelector: @selector(handleAppleEvent:withReplyEvent:)
forEventClass: kCoreEventClass // 'aevt'
andEventID: kAEOpenDocuments // 'odoc'
];
}
- (void)handleAppleEvent:(NSAppleEventDescriptor *)event withReplyEvent:(NSAppleEventDescriptor *)replyEvent;
{
NSAppleEventDescriptor *dirctObj = [ event descriptorForKeyword: keyDirectObject ];
DescType descriptorType = dirctObj.descriptorType;
if ( descriptorType == cAEList ) // 'list'
{
... some code here, calling pathFromDescriptor: for all items in list
}
else
{
NSString *path = [ self pathFromDescriptor: dirctObj ];
...
}
}
- (NSString *)pathFromDescriptor: (NSAppleEventDescriptor *)dirctObj;
{
DescType descriptorType = dirctObj.descriptorType;
if ( descriptorType == typeAlias ) // 'alis'
{
*** This is the stuff I need to test ***
… but I do not know how to trigger this path
… maybe some AppleScript?
}
else if ( descriptorType == typeFileURL ) // 'furl'
{
// get here via AppleScript
}
else if ( descriptorType == typeBookmarkData ) // 'bmrk'
{
// get here by dragging to dock
}
else // error
{
… error handling
}
}
Kind regards,
Gerriet.