• 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
Managed Object with Transformable Attribute (C Struct)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Managed Object with Transformable Attribute (C Struct)


  • Subject: Managed Object with Transformable Attribute (C Struct)
  • From: Richard Somers <email@hidden>
  • Date: Tue, 15 Dec 2009 17:24:48 -0700

I have a managed object with a transformable attribute. The attribute is a C struct and uses a custom value transformer. The transformer uses the depreciated NSArchiver but it is drop dead simple and it works.

I am trying to implement keyed archiving and can't figure out what to do or which way to go. I can't seem to see the forest for the trees and keep going around in circles in the documentation and on the web.

The C struct "Foo" is defined like this.

     typedef struct { double a; double b; double c; double d; } Bar;

     typedef struct { Bar e; Bar f; } Foo;

The current custom value transformer.

     @interface MyArchiveToDataTransformer : NSValueTransformer
     @end

     @implementation MyArchiveToDataTransformer
     + (Class)transformedValueClass
     {
          return [NSData class];
     }
     + (BOOL)allowsReverseTransformation
     {
          return YES;
     }
          - (id)transformedValue:(id)value
     {
          return [NSArchiver archivedDataWithRootObject:value];
     }
     - (id)reverseTransformedValue:(id)data
     {
          return [NSUnarchiver unarchiveObjectWithData:data];
     }
     @end

Any suggestions or insight for the lost and confused?

--Richard

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Managed Object with Transformable Attribute (C Struct)
      • From: Jerry Krinock <email@hidden>
  • Prev by Date: Re: NSUndoManager issues
  • Next by Date: App works when launched from Xcode, not from Finder
  • Previous by thread: Re: ipp help - need advice
  • Next by thread: Re: Managed Object with Transformable Attribute (C Struct)
  • Index(es):
    • Date
    • Thread