Parse bmrk NSAppleEventDescriptor from final cut pro x

54 views Asked by At

In Final cut pro, I shared to my application.

With following code

[[NSAppleEventManager sharedAppleEventManager] setEventHandler:self 
            andSelector:@selector(handleAppleEvent:withReplyEvent:) forEventClass:kCoreEventClass andEventID:kAEOpenDocuments];

- (void)handleAppleEvent:(NSAppleEventDescriptor *)event withReplyEvent:(NSAppleEventDescriptor *)replyEvent {
    NSLog(@"handleAppleEvent %@", event);
}

I got something like this.
'aevt''odoc'{ '----':[ 'bmrk'(1012/$626F6F6BF403000000000410300000000000000000000000000000000000000000000000000000000000000000000000C00200000400000003030000000200000500000001010000557365727300000009000000010100006D75796F756E676B6F0000000900000001010000446F63756D656E747300000007000000010100006161612E6D7866001000000001060000100000002000000034000000480000000800000004030000BC300600000000000800000...

I expected readable information likes /Users/hansome/Document/a.mov

How can I parse this?

1

There are 1 answers

0
muyoungko On

I found code without fully understanding.

    NSLog(@"handleAppleEvent 1 %@", event);

    NSAppleEventDescriptor* prop = [event paramDescriptorForKeyword:keyAEPropData];
    NSLog(@"handleAppleEvent prop %@", prop);
    
    NSAppleEventDescriptor* obj = [event paramDescriptorForKeyword:keyDirectObject];
    NSLog(@"handleAppleEvent obj %@", obj);
    
    
    if(obj != nil){
        for(int j=0;j<10;j++){
            NSAppleEventDescriptor* obj2 = [obj descriptorAtIndex:j];
            if(obj2 != nil){
                BOOL isStale;
                NSError* error;
                NSURL* url = [NSURL URLByResolvingBookmarkData:[obj2 data] options:NSURLBookmarkResolutionWithoutUI relativeToURL:nil bookmarkDataIsStale:&isStale error:&error];
                NSLog(@"handleAppleEvent bmrk %@", url);
            }
        }
    }