NSAppleEventDescriptor & Extracting a Date value

  • 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;
    }
    }
  • Steve Cronin wrote:

    > 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?

    objc-appscript's AEMCodecs class provides extensive bridging between
    ObjC classes and AE types, including typeLongDateTime. Use as-is - it
    should work on 10.3.9 onwards - or copy the bits you need.

    http://appscript.sourceforge.net/objc-appscript.html

    HTH

    has
    --
    http://appscript.sourceforge.net
    http://rb-appscript.rubyforge.org
previous month january 2008 next month
MTWTFSS
  1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31      
Go to today