Skip navigation.
 
mlNSAppleEventDescriptor & Extracting a Date value
FROM : Steve Cronin
DATE : Sat Jan 05 03:09:04 2008

Folks;

I need to pull a date out of an NSAppleEventDescriptor.
The code below is working for all of the other types.
How do I get the date value?
I've tried everything I can think of and all google-found code no 
longer compiles.
This is Tiger/XCode 2.4.1.

I know about Leopard and the 'bridge'; that is not an option here.

Thanks!
Steve

-(id) getValueFromDescriptor:(NSAppleEventDescriptor *)descriptor {
   NSDate *resultDate;
   switch ([descriptor descriptorType]) {
       case typeChar:
       case typeUnicodeText:
           return [descriptor stringValue];
       case typeBoolean:
           return [NSNumber numberWithBool:(BOOL)[descriptor booleanValue]];
       case typeTrue:
           return [NSNumber numberWithBool:YES];
       case typeFalse:
           return [NSNumber numberWithBool:NO];
       case typeNull:
           return [NSNull null];
       case typeSInt16:
           return [NSNumber numberWithInt:(short)[descriptor int32Value]];
       case typeSInt32:
           return [NSNumber numberWithInt:(int)[descriptor int32Value]];
       case typeUInt32:
           return [NSNumber numberWithLong:(unsigned int)[descriptor 
int32Value]];
       case typeLongDateTime:
           //this case gets exercised appropriately - I just can't extract 
the value

           return resultDate;
   }    
}

Related mailsAuthorDate
mlNSAppleEventDescriptor & Extracting a Date value Steve Cronin Jan 5, 03:09
mlRe: NSAppleEventDescriptor & Extracting a Date value has Jan 5, 12:27