Category that provides foundational support for object archiving and serialization in mulle-objc.
+classForCoder
- Returns class for encoding-classForCoder
- Returns instance-specific class+classNameForCoder
- Returns class name for encoding
-replacementObjectForCoder:
- Returns replacement for encoding-awakeAfterUsingCoder:
- Post-decode processing
// Implementing NSCoding
@interface MyObject : NSObject <NSCoding>
@end
@implementation MyObject
- (void)encodeWithCoder:(NSCoder *)coder
{
[coder encodeObject:self.name forKey:@"name"];
[coder encodeInteger:self.value forKey:@"value"];
}
- (id)initWithCoder:(NSCoder *)coder
{
self = [super init];
if (self) {
_name = [coder decodeObjectForKey:@"name"];
_value = [coder decodeIntegerForKey:@"value"];
}
return self;
}
@end
-
Version Management
- Increment versions properly
- Handle all versions
- Document changes
-
Data Migration
- Convert between versions
- Validate data
- Handle missing fields
-
Error Handling
- Validate decoded data
- Handle corruption
- Provide defaults
-
Compatibility
- Version handling
- Forward compatibility
- Backward compatibility
-
Security
- Data validation
- Safe decoding
- Secure storage