Skip to content

Latest commit

 

History

History
73 lines (56 loc) · 5.22 KB

NSObject+NSCodingSupport.md

File metadata and controls

73 lines (56 loc) · 5.22 KB

NSObject+NSCodingSupport

Category that provides foundational support for object archiving and serialization in mulle-objc.

Methods

Version Control

Class Substitution

Object Replacement

Usage Example

// 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

Important Notes

  1. Version Management

    • Increment versions properly
    • Handle all versions
    • Document changes
  2. Data Migration

    • Convert between versions
    • Validate data
    • Handle missing fields
  3. Error Handling

    • Validate decoded data
    • Handle corruption
    • Provide defaults
  4. Compatibility

    • Version handling
    • Forward compatibility
    • Backward compatibility
  5. Security

    • Data validation
    • Safe decoding
    • Secure storage