Skip to content

Instantly share code, notes, and snippets.


fra3il/0.h Secret

Last active Feb 2, 2016
What would you like to do?
[WP/160] How to store custom class using CoreData
@interface DBMetadata : NSObject <NSCoding> {
BOOL thumbnailExists;
long long totalBytes;
NSDate *lastModifiedDate;
NSString *path;
// ...
- (id)initWithCoder:(NSCoder *)coder {
if ((self = [super init])) {
thumbnailExists = [coder decodeBoolForKey:@"thumbnailExists"];
totalBytes = [coder decodeInt64ForKey:@"totalBytes"];
lastModifiedDate = [coder decodeObjectForKey:@"lastModifiedDate"];
path = [[coder decodeObjectForKey:@"path"] retain];
// ...
return self;
- (void)encodeWithCoder:(NSCoder *)coder {
[coder encodeBool:thumbnailExists forKey:@"thumbnailExists"];
[coder encodeInt64:totalBytes forKey:@"totalBytes"];
[coder encodeObject:lastModifiedDate forKey:@"lastModifiedDate"];
[coder encodeObject:path forKey:@"path"];
// ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment