Created
November 29, 2011 23:36
-
-
Save OneSadCookie/1407168 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)encodeWithCoder:(NSCoder *)aCoder | |
{ | |
[super encodeWithCoder:aCoder]; | |
[aCoder encodeObject:_vValue forKey:@"vValue"]; | |
} | |
- (id)initWithCoder:(NSCoder *)aDecoder | |
{ | |
self = [super initWithCoder:aDecoder]; | |
if (!self) return nil; | |
_vValue = [[aDecoder decodeObjectForKey:@"vValue"] retain]; // don't retain in ARC | |
if (/* !vValue || */ ![vValue isKindOfClass:[Whatever class]]) | |
{ | |
[self dealloc]; // not in ARC | |
return nil; | |
} | |
return self; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Also helpful is my thoughtfully compiled NSCoding Tips, though it looks like you're trying to show conditional encoding (which is slightly more fun to do).