Note that there are some explanatory texts on larger screens.

plurals
  1. POSplit Data for NSKeyedArchiver and NSKeyedUnarchiver
    primarykey
    data
    text
    <p>Edit (2012/10/22): Restating this question in hopefully clearer terms.</p> <p>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.</p> <p>For example, suppose we have a class with something like this:</p> <pre><code>@interface SomeClass { NSString *ivar1; NSString *ivar2; NSString *ivar3; SomeClass *ivarZ; } ... @end </code></pre> <p>Somewhere we have an instance:</p> <pre><code>SomeClass *someObject; </code></pre> <p>What I want to do is something like the following on saving:</p> <pre><code>NSData *prefDat = [KeyedMultiArchiver archiveRootObject:someObject withPartitionKey:@"DataForNSUserDefaults"]; NSData *permDat = [KeyedMultiArchiver archiveRootObject:someObject withPartitionKey:@"DataForPermanentStorage"]; /* save prefDat to NSUserDefaults */; /* save permDat to some appropriate NSURL */; </code></pre> <p>And then on unarchiving:</p> <pre><code>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"]; </code></pre> <p>Where <code>ivar1</code>s might get saved to <code>NSUserDefaults</code> and <code>ivar2</code>s, <code>ivar3</code>s to disk somewhere.</p> <p>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!</p> <p>Will post final product.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload