Edit (2012/10/22): Restating this question in hopefully clearer terms.
Essentially, what I'm looking for is some NSCoder that can (un)archive between multiple locations. Some of the encoded objects primitives should be saved in location A while others should be saved in specified location B, etc.
For example, suppose we have a class with something like this:
@interface SomeClass
{
NSString *ivar1;
NSString *ivar2;
NSString *ivar3;
SomeClass *ivarZ;
}
...
@end
Somewhere we have an instance:
SomeClass *someObject;
What I want to do is something like the following on saving:
NSData *prefDat = [KeyedMultiArchiver archiveRootObject:someObject
withPartitionKey:@"DataForNSUserDefaults"];
NSData *permDat = [KeyedMultiArchiver archiveRootObject:someObject
withPartitionKey:@"DataForPermanentStorage"];
/* save prefDat to NSUserDefaults */;
/* save permDat to some appropriate NSURL */;
And then on unarchiving:
SomeClass *anotherObject = [SomeClass new];
NSData *prefDat = /* get from NSUserDefaults */;
NSData *permDat = /* get from appropriate NSURL */;
[KeyedMultiUnarchiver unarchiveData:prefDat
intoObject:anotherObject
withPartitionKey:@"DataForNSUserDefaults"];
[KeyedMultiUnarchiver unarchiveData:permDat
intoObject:anotherObject
withPartitionKey:@"DataForPermanentStorage"];
Where ivar1
s might get saved to NSUserDefaults
and ivar2
s, ivar3
s to disk somewhere.
I'll probably end up coding my own solution for this, but if you guys come up with any brilliant alternatives please let me know!
Will post final product.