I would like to serialize excerpts from a collection of objects that do not themselves conform to NSCoding
to a file. What's the best way to achieve this without transformation the collected objects an intermediary representation (one that would conform to NSCoding
)? The (apparent) problem arises, because NSKeyedArchiver
requires unique keys, and there is no NSArchiver
on iOS.
For instance, the following will not work, because values are overwritten inside the loop as keys are reused. Calculating unique key strings from some loop index would be possible but quite a nuisance:
for (MyObject *object in myObjects) {
NSString *someString = myObject.someString; // excerpted string
[archiver encodeObject: someString withKey: @"someString"]
}