diff --git a/DCTImageCache.xcodeproj/project.pbxproj b/DCTImageCache.xcodeproj/project.pbxproj index 943204c..59c4f0a 100644 --- a/DCTImageCache.xcodeproj/project.pbxproj +++ b/DCTImageCache.xcodeproj/project.pbxproj @@ -21,6 +21,8 @@ 24B3EEC915A2EB1F00D5E63C /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 24B3EEC815A2EB1F00D5E63C /* AppDelegate.m */; }; 24B3EECC15A2EB1F00D5E63C /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 24B3EECB15A2EB1F00D5E63C /* ViewController.m */; }; 24B3EECF15A2EB1F00D5E63C /* ViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 24B3EECD15A2EB1F00D5E63C /* ViewController.xib */; }; + 24F2DB23165FED99008F58D5 /* _DCTImageCacheItem.m in Sources */ = {isa = PBXBuildFile; fileRef = 24F2DB22165FED99008F58D5 /* _DCTImageCacheItem.m */; }; + 24F2DB27165FEDDC008F58D5 /* __DCTImageCacheItem.m in Sources */ = {isa = PBXBuildFile; fileRef = 24F2DB26165FEDDC008F58D5 /* __DCTImageCacheItem.m */; }; 24F7CB52158A1B9D00B2E33E /* SenTestingKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 24F7CB51158A1B9D00B2E33E /* SenTestingKit.framework */; }; 24F7CB54158A1B9D00B2E33E /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 24F7CB53158A1B9D00B2E33E /* UIKit.framework */; }; 24F7CB55158A1B9D00B2E33E /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 24F7CB42158A1B9D00B2E33E /* Foundation.framework */; }; @@ -72,6 +74,10 @@ 24B3EEDA15A30F6600D5E63C /* _DCTImageCacheHashStore.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = _DCTImageCacheHashStore.m; sourceTree = ""; }; 24B3EEDD15A311D400D5E63C /* _DCTMemoryImageCache.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = _DCTMemoryImageCache.h; sourceTree = ""; }; 24B3EEDE15A311D400D5E63C /* _DCTMemoryImageCache.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = _DCTMemoryImageCache.m; sourceTree = ""; }; + 24F2DB21165FED99008F58D5 /* _DCTImageCacheItem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = _DCTImageCacheItem.h; sourceTree = ""; }; + 24F2DB22165FED99008F58D5 /* _DCTImageCacheItem.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = _DCTImageCacheItem.m; sourceTree = ""; }; + 24F2DB25165FEDDC008F58D5 /* __DCTImageCacheItem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = __DCTImageCacheItem.h; sourceTree = ""; }; + 24F2DB26165FEDDC008F58D5 /* __DCTImageCacheItem.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = __DCTImageCacheItem.m; sourceTree = ""; }; 24F7CB42158A1B9D00B2E33E /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; 24F7CB46158A1B9D00B2E33E /* DCTImageCache-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "DCTImageCache-Prefix.pch"; sourceTree = ""; }; 24F7CB47158A1B9D00B2E33E /* DCTImageCache.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DCTImageCache.h; sourceTree = ""; }; @@ -83,7 +89,7 @@ 24F7CB5D158A1B9D00B2E33E /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; 24F7CB5F158A1B9D00B2E33E /* DCTImageCacheTests.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DCTImageCacheTests.h; sourceTree = ""; }; 24F7CB60158A1B9D00B2E33E /* DCTImageCacheTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = DCTImageCacheTests.m; sourceTree = ""; }; - 24FCFA94165FEAB3006208A7 /* DCTImageCacheBundle.bundle */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = DCTImageCacheBundle.bundle; sourceTree = BUILT_PRODUCTS_DIR; }; + 24FCFA94165FEAB3006208A7 /* DCTImageCache.bundle */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = DCTImageCache.bundle; sourceTree = BUILT_PRODUCTS_DIR; }; 24FCFA95165FEAB3006208A7 /* CoreFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreFoundation.framework; path = System/Library/Frameworks/CoreFoundation.framework; sourceTree = SDKROOT; }; 24FCFA99165FEAB3006208A7 /* DCTImageCacheBundle-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "DCTImageCacheBundle-Info.plist"; sourceTree = ""; }; 24FCFAA5165FEB25006208A7 /* DCTImageCache.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = DCTImageCache.xcdatamodel; sourceTree = ""; }; @@ -171,7 +177,7 @@ 24F7CB50158A1B9D00B2E33E /* DCTImageCacheTests.octest */, 24B3EEB815A2EB1F00D5E63C /* DCTImageCaccheDemo.app */, 2437B67715B97BA600750117 /* libDCTImageCache.a */, - 24FCFA94165FEAB3006208A7 /* DCTImageCacheBundle.bundle */, + 24FCFA94165FEAB3006208A7 /* DCTImageCache.bundle */, ); name = Products; sourceTree = ""; @@ -195,6 +201,10 @@ 24F7CB49158A1B9D00B2E33E /* DCTImageCache.m */, 24B3EED515A30EEB00D5E63C /* _DCTDiskImageCache.h */, 24B3EED615A30EEB00D5E63C /* _DCTDiskImageCache.m */, + 24F2DB25165FEDDC008F58D5 /* __DCTImageCacheItem.h */, + 24F2DB26165FEDDC008F58D5 /* __DCTImageCacheItem.m */, + 24F2DB21165FED99008F58D5 /* _DCTImageCacheItem.h */, + 24F2DB22165FED99008F58D5 /* _DCTImageCacheItem.m */, 24B3EEDD15A311D400D5E63C /* _DCTMemoryImageCache.h */, 24B3EEDE15A311D400D5E63C /* _DCTMemoryImageCache.m */, 24B3EED915A30F6600D5E63C /* _DCTImageCacheHashStore.h */, @@ -318,7 +328,7 @@ ); name = DCTImageCacheBundle; productName = DCTImageCacheBundle; - productReference = 24FCFA94165FEAB3006208A7 /* DCTImageCacheBundle.bundle */; + productReference = 24FCFA94165FEAB3006208A7 /* DCTImageCache.bundle */; productType = "com.apple.product-type.bundle"; }; /* End PBXNativeTarget section */ @@ -402,6 +412,8 @@ 2437B68515B97BD700750117 /* _DCTDiskImageCache.m in Sources */, 2437B68615B97BD700750117 /* _DCTMemoryImageCache.m in Sources */, 2437B68715B97BD700750117 /* _DCTImageCacheHashStore.m in Sources */, + 24F2DB23165FED99008F58D5 /* _DCTImageCacheItem.m in Sources */, + 24F2DB27165FEDDC008F58D5 /* __DCTImageCacheItem.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -625,7 +637,7 @@ INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Bundles"; MACOSX_DEPLOYMENT_TARGET = 10.8; ONLY_ACTIVE_ARCH = YES; - PRODUCT_NAME = "$(TARGET_NAME)"; + PRODUCT_NAME = DCTImageCache; WRAPPER_EXTENSION = bundle; }; name = Debug; @@ -643,7 +655,7 @@ INFOPLIST_FILE = "DCTImageCacheBundle/DCTImageCacheBundle-Info.plist"; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Bundles"; MACOSX_DEPLOYMENT_TARGET = 10.8; - PRODUCT_NAME = "$(TARGET_NAME)"; + PRODUCT_NAME = DCTImageCache; WRAPPER_EXTENSION = bundle; }; name = Release; @@ -694,6 +706,7 @@ 24FCFA9F165FEAB3006208A7 /* Release */, ); defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; }; /* End XCConfigurationList section */ diff --git a/DCTImageCache/DCTImageCache.m b/DCTImageCache/DCTImageCache.m index 46fb8cf..28e2e72 100644 --- a/DCTImageCache/DCTImageCache.m +++ b/DCTImageCache/DCTImageCache.m @@ -19,7 +19,7 @@ @implementation DCTImageCache { } #pragma mark NSObject - +/* + (void)initialize { @autoreleasepool { NSDate *now = [NSDate date]; @@ -46,7 +46,7 @@ + (void)initialize { }]; } } - +*/ #pragma mark DCTImageCache - (id)diskCache { diff --git a/DCTImageCache/_DCTDiskImageCache.h b/DCTImageCache/_DCTDiskImageCache.h index 49b8b1c..5cdfe18 100644 --- a/DCTImageCache/_DCTDiskImageCache.h +++ b/DCTImageCache/_DCTDiskImageCache.h @@ -11,7 +11,7 @@ @interface _DCTDiskImageCache : NSObject - (id)initWithPath:(NSString *)path; -- (void)fetchAttributesForImageWithKey:(NSString *)key size:(CGSize)size handler:(void (^)(NSDictionary *))handler; +/*- (void)fetchAttributesForImageWithKey:(NSString *)key size:(CGSize)size handler:(void (^)(NSDictionary *))handler; - (void)enumerateKeysUsingBlock:(void (^)(NSString *key, BOOL *stop))block; - (void)enumerateSizesForKey:(NSString *)key usingBlock:(void (^)(CGSize size, BOOL *stop))block; -@end \ No newline at end of file +*/@end \ No newline at end of file diff --git a/DCTImageCache/_DCTDiskImageCache.m b/DCTImageCache/_DCTDiskImageCache.m index 4dc4558..44f3792 100644 --- a/DCTImageCache/_DCTDiskImageCache.m +++ b/DCTImageCache/_DCTDiskImageCache.m @@ -7,95 +7,126 @@ // #import "_DCTDiskImageCache.h" -#import "_DCTImageCacheHashStore.h" +#import "_DCTImageCacheItem.h" +#import @implementation _DCTDiskImageCache { - __strong NSString *_path; - __strong _DCTImageCacheHashStore *_hashStore; - __strong NSFileManager *_fileManager; __strong NSOperationQueue *_queue; + + NSManagedObjectContext *_managedObjectContext; + //NSManagedObjectContext *savingContext; + //NSManagedObjectContext *fetchingContext; +} + ++ (NSBundle *)bundle { + static NSBundle *bundle; + static dispatch_once_t bundleToken; + dispatch_once(&bundleToken, ^{ + NSDirectoryEnumerator *enumerator = [[NSFileManager new] enumeratorAtURL:[[NSBundle mainBundle] bundleURL] + includingPropertiesForKeys:nil + options:NSDirectoryEnumerationSkipsHiddenFiles + errorHandler:NULL]; + + for (NSURL *URL in enumerator) + if ([[URL lastPathComponent] isEqualToString:@"DCTImageCache.bundle"]) + bundle = [NSBundle bundleWithURL:URL]; + }); + + return bundle; } - (id)initWithPath:(NSString *)path { if (!(self = [super init])) return nil; - _queue = [NSOperationQueue new]; - [_queue setMaxConcurrentOperationCount:1]; - - [self _performBlock:^{ - _path = [path copy]; - _hashStore = [[_DCTImageCacheHashStore alloc] initWithPath:path]; - _fileManager = [NSFileManager new]; - [_fileManager createDirectoryAtPath:_path withIntermediateDirectories:YES attributes:nil error:nil]; - }]; + NSURL *storeURL = [[[NSURL alloc] initFileURLWithPath:path] URLByAppendingPathComponent:@"store"]; + NSURL *modelURL = [[[self class] bundle] URLForResource:@"DCTImageCache" withExtension:@"momd"]; + NSManagedObjectModel *model = [[NSManagedObjectModel alloc] initWithContentsOfURL:modelURL]; + NSPersistentStoreCoordinator *coordinator = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel:model]; + [coordinator addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:storeURL options:nil error:NULL]; + _managedObjectContext = [[NSManagedObjectContext alloc] initWithConcurrencyType:NSPrivateQueueConcurrencyType]; + _managedObjectContext.persistentStoreCoordinator = coordinator; return self; } - (void)removeAllImages { - [self _performBlock:^{ - [_fileManager removeItemAtPath:_path error:nil]; - [_fileManager createDirectoryAtPath:_path withIntermediateDirectories:YES attributes:nil error:nil]; + [_managedObjectContext performBlock:^{ + NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] initWithEntityName:[_DCTImageCacheItem entityName]]; + NSArray *items = [_managedObjectContext executeFetchRequest:fetchRequest error:NULL]; + for (_DCTImageCacheItem *item in items) [_managedObjectContext deleteObject:item]; }]; } - (void)removeImageForKey:(NSString *)key size:(CGSize)size { - [self _performBlock:^{ - NSString *path = [self _pathForKey:key size:size]; - [_fileManager removeItemAtPath:path error:nil]; + [_managedObjectContext performBlock:^{ + NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] initWithEntityName:[_DCTImageCacheItem entityName]]; + NSPredicate *keyPredicate = [NSPredicate predicateWithFormat:@"%K == %@", _DCTImageCacheItemAttributes.key, key]; + NSPredicate *sizePredicate = [NSPredicate predicateWithFormat:@"%K == %@", _DCTImageCacheItemAttributes.sizeString, NSStringFromCGSize(size)]; + fetchRequest.predicate = [NSCompoundPredicate andPredicateWithSubpredicates:@[keyPredicate, sizePredicate]]; + NSArray *items = [_managedObjectContext executeFetchRequest:fetchRequest error:NULL]; + for (_DCTImageCacheItem *item in items) [_managedObjectContext deleteObject:item]; }]; } - (void)removeAllImagesForKey:(NSString *)key { - [self _performBlock:^{ - NSString *directoryPath = [self _pathForKey:key]; - [_fileManager removeItemAtPath:directoryPath error:nil]; - [_hashStore removeHashForKey:key]; + [_managedObjectContext performBlock:^{ + NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] initWithEntityName:[_DCTImageCacheItem entityName]]; + fetchRequest.predicate = [NSPredicate predicateWithFormat:@"%K == %@", _DCTImageCacheItemAttributes.key, key]; + NSArray *items = [_managedObjectContext executeFetchRequest:fetchRequest error:NULL]; + for (_DCTImageCacheItem *item in items) [_managedObjectContext deleteObject:item]; }]; } - (UIImage *)imageForKey:(NSString *)key size:(CGSize)size { - - __block UIImage *image = nil; - - [self _performBlockAndWait:^{ - image = [self _imageForKey:key size:size]; + __block UIImage *image; + [_managedObjectContext performBlockAndWait:^{ + NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] initWithEntityName:[_DCTImageCacheItem entityName]]; + NSPredicate *keyPredicate = [NSPredicate predicateWithFormat:@"%K == %@", _DCTImageCacheItemAttributes.key, key]; + NSPredicate *sizePredicate = [NSPredicate predicateWithFormat:@"%K == %@", _DCTImageCacheItemAttributes.sizeString, NSStringFromCGSize(size)]; + fetchRequest.predicate = [NSCompoundPredicate andPredicateWithSubpredicates:@[keyPredicate, sizePredicate]]; + NSArray *items = [_managedObjectContext executeFetchRequest:fetchRequest error:NULL]; + _DCTImageCacheItem *item = [items lastObject]; + image = [UIImage imageWithData:item.imageData]; }]; - return image; } - (BOOL)hasImageForKey:(NSString *)key size:(CGSize)size { - __block BOOL hasImage = NO; - - [self _performBlockAndWait:^{ - NSString *imagePath = [self _pathForKey:key size:size]; - hasImage = [_fileManager fileExistsAtPath:imagePath]; + [_managedObjectContext performBlockAndWait:^{ + NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] initWithEntityName:[_DCTImageCacheItem entityName]]; + NSPredicate *keyPredicate = [NSPredicate predicateWithFormat:@"%K == %@", _DCTImageCacheItemAttributes.key, key]; + NSPredicate *sizePredicate = [NSPredicate predicateWithFormat:@"%K == %@", _DCTImageCacheItemAttributes.sizeString, NSStringFromCGSize(size)]; + fetchRequest.predicate = [NSCompoundPredicate andPredicateWithSubpredicates:@[keyPredicate, sizePredicate]]; + NSArray *items = [_managedObjectContext executeFetchRequest:fetchRequest error:NULL]; + hasImage = items.count > 0; }]; - - return hasImage; + return hasImage; } - (void)fetchImageForKey:(NSString *)key size:(CGSize)size handler:(void (^)(UIImage *))handler { - [self _performWithPriority:NSOperationQueuePriorityVeryHigh block:^{ - UIImage *image = [self _imageForKey:key size:size]; + [_managedObjectContext performBlock:^{ + NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] initWithEntityName:[_DCTImageCacheItem entityName]]; + NSPredicate *keyPredicate = [NSPredicate predicateWithFormat:@"%K == %@", _DCTImageCacheItemAttributes.key, key]; + NSPredicate *sizePredicate = [NSPredicate predicateWithFormat:@"%K == %@", _DCTImageCacheItemAttributes.sizeString, NSStringFromCGSize(size)]; + fetchRequest.predicate = [NSCompoundPredicate andPredicateWithSubpredicates:@[keyPredicate, sizePredicate]]; + NSArray *items = [_managedObjectContext executeFetchRequest:fetchRequest error:NULL]; + _DCTImageCacheItem *item = [items lastObject]; + UIImage *image = [UIImage imageWithData:item.imageData]; handler(image); }]; } - (void)setImage:(UIImage *)image forKey:(NSString *)key size:(CGSize)size { - [self _performBlock:^{ - NSString *path = [self _pathForKey:key]; - NSString *imagePath = [self _pathForKey:key size:size]; - - if (![_fileManager fileExistsAtPath:path]) - [_fileManager createDirectoryAtPath:path withIntermediateDirectories:YES attributes:nil error:nil]; - - [_fileManager createFileAtPath:imagePath contents:UIImagePNGRepresentation(image) attributes:nil]; + [_managedObjectContext performBlock:^{ + _DCTImageCacheItem *item = [_DCTImageCacheItem insertInManagedObjectContext:_managedObjectContext]; + item.key = key; + item.sizeString = NSStringFromCGSize(size); + item.imageData = UIImagePNGRepresentation(image); + [_managedObjectContext save:NULL]; }]; } - +/* - (void)fetchAttributesForImageWithKey:(NSString *)key size:(CGSize)size handler:(void (^)(NSDictionary *))handler { [self _performBlock:^{ NSString *path = [self _pathForKey:key size:size]; @@ -121,41 +152,6 @@ - (void)enumerateSizesForKey:(NSString *)key usingBlock:(void (^)(CGSize size, B block(CGSizeFromString(filename), stop); }]; }]; -} - -#pragma mark Internal - -- (void)_performBlock:(void(^)())block { - [_queue addOperationWithBlock:block]; -} - -- (void)_performWithPriority:(NSOperationQueuePriority)priority block:(void(^)())block { - NSBlockOperation *blockOperation = [NSBlockOperation blockOperationWithBlock:block]; - [blockOperation setQueuePriority:priority]; - [_queue addOperation:blockOperation]; -} - -- (void)_performBlockAndWait:(void(^)())block { - NSBlockOperation *blockOperation = [NSBlockOperation blockOperationWithBlock:block]; - [blockOperation setQueuePriority:NSOperationQueuePriorityVeryHigh]; - [_queue addOperation:blockOperation]; - [blockOperation waitUntilFinished]; -} - -- (UIImage *)_imageForKey:(NSString *)key size:(CGSize)size { - NSString *imagePath = [self _pathForKey:key size:size]; - NSData *data = [_fileManager contentsAtPath:imagePath]; - return [UIImage imageWithData:data]; -} - -- (NSString *)_pathForKey:(NSString *)key size:(CGSize)size { - NSString *path = [self _pathForKey:key]; - return [path stringByAppendingPathComponent:NSStringFromCGSize(size)]; -} - -- (NSString *)_pathForKey:(NSString *)key { - NSString *hash = [_hashStore hashForKey:key]; - return [_path stringByAppendingPathComponent:hash]; -} +}*/ @end diff --git a/DCTImageCache/_DCTImageCacheItem.h b/DCTImageCache/_DCTImageCacheItem.h new file mode 100644 index 0000000..3937c7b --- /dev/null +++ b/DCTImageCache/_DCTImageCacheItem.h @@ -0,0 +1,5 @@ +#import "__DCTImageCacheItem.h" + +@interface _DCTImageCacheItem : __DCTImageCacheItem {} +// Custom logic goes here. +@end diff --git a/DCTImageCache/_DCTImageCacheItem.m b/DCTImageCache/_DCTImageCacheItem.m new file mode 100644 index 0000000..86b28be --- /dev/null +++ b/DCTImageCache/_DCTImageCacheItem.m @@ -0,0 +1,7 @@ +#import "_DCTImageCacheItem.h" + +@implementation _DCTImageCacheItem + +// Custom logic goes here. + +@end diff --git a/DCTImageCache/__DCTImageCacheItem.h b/DCTImageCache/__DCTImageCacheItem.h new file mode 100644 index 0000000..857ee1d --- /dev/null +++ b/DCTImageCache/__DCTImageCacheItem.h @@ -0,0 +1,89 @@ +// DO NOT EDIT. This file is machine-generated and constantly overwritten. +// Make changes to _DCTImageCacheItem.h instead. + +#import + + +extern const struct _DCTImageCacheItemAttributes { + __unsafe_unretained NSString *imageData; + __unsafe_unretained NSString *key; + __unsafe_unretained NSString *sizeString; +} _DCTImageCacheItemAttributes; + +extern const struct _DCTImageCacheItemRelationships { +} _DCTImageCacheItemRelationships; + +extern const struct _DCTImageCacheItemFetchedProperties { +} _DCTImageCacheItemFetchedProperties; + + + + + + +@interface _DCTImageCacheItemID : NSManagedObjectID {} +@end + +@interface __DCTImageCacheItem : NSManagedObject {} ++ (id)insertInManagedObjectContext:(NSManagedObjectContext*)moc_; ++ (NSString*)entityName; ++ (NSEntityDescription*)entityInManagedObjectContext:(NSManagedObjectContext*)moc_; +- (_DCTImageCacheItemID*)objectID; + + + + +@property (nonatomic, strong) NSData* imageData; + + +//- (BOOL)validateImageData:(id*)value_ error:(NSError**)error_; + + + + +@property (nonatomic, strong) NSString* key; + + +//- (BOOL)validateKey:(id*)value_ error:(NSError**)error_; + + + + +@property (nonatomic, strong) NSString* sizeString; + + +//- (BOOL)validateSizeString:(id*)value_ error:(NSError**)error_; + + + + + + +@end + +@interface __DCTImageCacheItem (CoreDataGeneratedAccessors) + +@end + +@interface __DCTImageCacheItem (CoreDataGeneratedPrimitiveAccessors) + + +- (NSData*)primitiveImageData; +- (void)setPrimitiveImageData:(NSData*)value; + + + + +- (NSString*)primitiveKey; +- (void)setPrimitiveKey:(NSString*)value; + + + + +- (NSString*)primitiveSizeString; +- (void)setPrimitiveSizeString:(NSString*)value; + + + + +@end diff --git a/DCTImageCache/__DCTImageCacheItem.m b/DCTImageCache/__DCTImageCacheItem.m new file mode 100644 index 0000000..098da90 --- /dev/null +++ b/DCTImageCache/__DCTImageCacheItem.m @@ -0,0 +1,77 @@ +// DO NOT EDIT. This file is machine-generated and constantly overwritten. +// Make changes to _DCTImageCacheItem.m instead. + +#import "__DCTImageCacheItem.h" + +const struct _DCTImageCacheItemAttributes _DCTImageCacheItemAttributes = { + .imageData = @"imageData", + .key = @"key", + .sizeString = @"sizeString", +}; + +const struct _DCTImageCacheItemRelationships _DCTImageCacheItemRelationships = { +}; + +const struct _DCTImageCacheItemFetchedProperties _DCTImageCacheItemFetchedProperties = { +}; + +@implementation _DCTImageCacheItemID +@end + +@implementation __DCTImageCacheItem + ++ (id)insertInManagedObjectContext:(NSManagedObjectContext*)moc_ { + NSParameterAssert(moc_); + return [NSEntityDescription insertNewObjectForEntityForName:@"DCTImageCacheItem" inManagedObjectContext:moc_]; +} + ++ (NSString*)entityName { + return @"DCTImageCacheItem"; +} + ++ (NSEntityDescription*)entityInManagedObjectContext:(NSManagedObjectContext*)moc_ { + NSParameterAssert(moc_); + return [NSEntityDescription entityForName:@"DCTImageCacheItem" inManagedObjectContext:moc_]; +} + +- (_DCTImageCacheItemID*)objectID { + return (_DCTImageCacheItemID*)[super objectID]; +} + ++ (NSSet *)keyPathsForValuesAffectingValueForKey:(NSString *)key { + NSSet *keyPaths = [super keyPathsForValuesAffectingValueForKey:key]; + + + return keyPaths; +} + + + + +@dynamic imageData; + + + + + + +@dynamic key; + + + + + + +@dynamic sizeString; + + + + + + + + + + + +@end diff --git a/DCTImageCacheBundle/DCTImageCache.xcdatamodeld/DCTImageCache.xcdatamodel/contents b/DCTImageCacheBundle/DCTImageCache.xcdatamodeld/DCTImageCache.xcdatamodel/contents index 0923d07..4c9a5c5 100644 --- a/DCTImageCacheBundle/DCTImageCache.xcdatamodeld/DCTImageCache.xcdatamodel/contents +++ b/DCTImageCacheBundle/DCTImageCache.xcdatamodeld/DCTImageCache.xcdatamodel/contents @@ -1,4 +1,11 @@ - - + + + + + + + + + \ No newline at end of file diff --git a/_DCTImageCacheItem.h b/_DCTImageCacheItem.h new file mode 100644 index 0000000..a98570d --- /dev/null +++ b/_DCTImageCacheItem.h @@ -0,0 +1,89 @@ +// DO NOT EDIT. This file is machine-generated and constantly overwritten. +// Make changes to DCTImageCacheItem.h instead. + +#import + + +extern const struct DCTImageCacheItemAttributes { + __unsafe_unretained NSString *imageData; + __unsafe_unretained NSString *key; + __unsafe_unretained NSString *sizeString; +} DCTImageCacheItemAttributes; + +extern const struct DCTImageCacheItemRelationships { +} DCTImageCacheItemRelationships; + +extern const struct DCTImageCacheItemFetchedProperties { +} DCTImageCacheItemFetchedProperties; + + + + + + +@interface DCTImageCacheItemID : NSManagedObjectID {} +@end + +@interface _DCTImageCacheItem : NSManagedObject {} ++ (id)insertInManagedObjectContext:(NSManagedObjectContext*)moc_; ++ (NSString*)entityName; ++ (NSEntityDescription*)entityInManagedObjectContext:(NSManagedObjectContext*)moc_; +- (DCTImageCacheItemID*)objectID; + + + + +@property (nonatomic, strong) NSData* imageData; + + +//- (BOOL)validateImageData:(id*)value_ error:(NSError**)error_; + + + + +@property (nonatomic, strong) NSString* key; + + +//- (BOOL)validateKey:(id*)value_ error:(NSError**)error_; + + + + +@property (nonatomic, strong) NSString* sizeString; + + +//- (BOOL)validateSizeString:(id*)value_ error:(NSError**)error_; + + + + + + +@end + +@interface _DCTImageCacheItem (CoreDataGeneratedAccessors) + +@end + +@interface _DCTImageCacheItem (CoreDataGeneratedPrimitiveAccessors) + + +- (NSData*)primitiveImageData; +- (void)setPrimitiveImageData:(NSData*)value; + + + + +- (NSString*)primitiveKey; +- (void)setPrimitiveKey:(NSString*)value; + + + + +- (NSString*)primitiveSizeString; +- (void)setPrimitiveSizeString:(NSString*)value; + + + + +@end diff --git a/_DCTImageCacheItem.m b/_DCTImageCacheItem.m new file mode 100644 index 0000000..0482075 --- /dev/null +++ b/_DCTImageCacheItem.m @@ -0,0 +1,77 @@ +// DO NOT EDIT. This file is machine-generated and constantly overwritten. +// Make changes to DCTImageCacheItem.m instead. + +#import "_DCTImageCacheItem.h" + +const struct DCTImageCacheItemAttributes DCTImageCacheItemAttributes = { + .imageData = @"imageData", + .key = @"key", + .sizeString = @"sizeString", +}; + +const struct DCTImageCacheItemRelationships DCTImageCacheItemRelationships = { +}; + +const struct DCTImageCacheItemFetchedProperties DCTImageCacheItemFetchedProperties = { +}; + +@implementation DCTImageCacheItemID +@end + +@implementation _DCTImageCacheItem + ++ (id)insertInManagedObjectContext:(NSManagedObjectContext*)moc_ { + NSParameterAssert(moc_); + return [NSEntityDescription insertNewObjectForEntityForName:@"DCTImageCacheItem" inManagedObjectContext:moc_]; +} + ++ (NSString*)entityName { + return @"DCTImageCacheItem"; +} + ++ (NSEntityDescription*)entityInManagedObjectContext:(NSManagedObjectContext*)moc_ { + NSParameterAssert(moc_); + return [NSEntityDescription entityForName:@"DCTImageCacheItem" inManagedObjectContext:moc_]; +} + +- (DCTImageCacheItemID*)objectID { + return (DCTImageCacheItemID*)[super objectID]; +} + ++ (NSSet *)keyPathsForValuesAffectingValueForKey:(NSString *)key { + NSSet *keyPaths = [super keyPathsForValuesAffectingValueForKey:key]; + + + return keyPaths; +} + + + + +@dynamic imageData; + + + + + + +@dynamic key; + + + + + + +@dynamic sizeString; + + + + + + + + + + + +@end diff --git a/__DCTImageCacheItem.h b/__DCTImageCacheItem.h new file mode 100644 index 0000000..857ee1d --- /dev/null +++ b/__DCTImageCacheItem.h @@ -0,0 +1,89 @@ +// DO NOT EDIT. This file is machine-generated and constantly overwritten. +// Make changes to _DCTImageCacheItem.h instead. + +#import + + +extern const struct _DCTImageCacheItemAttributes { + __unsafe_unretained NSString *imageData; + __unsafe_unretained NSString *key; + __unsafe_unretained NSString *sizeString; +} _DCTImageCacheItemAttributes; + +extern const struct _DCTImageCacheItemRelationships { +} _DCTImageCacheItemRelationships; + +extern const struct _DCTImageCacheItemFetchedProperties { +} _DCTImageCacheItemFetchedProperties; + + + + + + +@interface _DCTImageCacheItemID : NSManagedObjectID {} +@end + +@interface __DCTImageCacheItem : NSManagedObject {} ++ (id)insertInManagedObjectContext:(NSManagedObjectContext*)moc_; ++ (NSString*)entityName; ++ (NSEntityDescription*)entityInManagedObjectContext:(NSManagedObjectContext*)moc_; +- (_DCTImageCacheItemID*)objectID; + + + + +@property (nonatomic, strong) NSData* imageData; + + +//- (BOOL)validateImageData:(id*)value_ error:(NSError**)error_; + + + + +@property (nonatomic, strong) NSString* key; + + +//- (BOOL)validateKey:(id*)value_ error:(NSError**)error_; + + + + +@property (nonatomic, strong) NSString* sizeString; + + +//- (BOOL)validateSizeString:(id*)value_ error:(NSError**)error_; + + + + + + +@end + +@interface __DCTImageCacheItem (CoreDataGeneratedAccessors) + +@end + +@interface __DCTImageCacheItem (CoreDataGeneratedPrimitiveAccessors) + + +- (NSData*)primitiveImageData; +- (void)setPrimitiveImageData:(NSData*)value; + + + + +- (NSString*)primitiveKey; +- (void)setPrimitiveKey:(NSString*)value; + + + + +- (NSString*)primitiveSizeString; +- (void)setPrimitiveSizeString:(NSString*)value; + + + + +@end diff --git a/__DCTImageCacheItem.m b/__DCTImageCacheItem.m new file mode 100644 index 0000000..098da90 --- /dev/null +++ b/__DCTImageCacheItem.m @@ -0,0 +1,77 @@ +// DO NOT EDIT. This file is machine-generated and constantly overwritten. +// Make changes to _DCTImageCacheItem.m instead. + +#import "__DCTImageCacheItem.h" + +const struct _DCTImageCacheItemAttributes _DCTImageCacheItemAttributes = { + .imageData = @"imageData", + .key = @"key", + .sizeString = @"sizeString", +}; + +const struct _DCTImageCacheItemRelationships _DCTImageCacheItemRelationships = { +}; + +const struct _DCTImageCacheItemFetchedProperties _DCTImageCacheItemFetchedProperties = { +}; + +@implementation _DCTImageCacheItemID +@end + +@implementation __DCTImageCacheItem + ++ (id)insertInManagedObjectContext:(NSManagedObjectContext*)moc_ { + NSParameterAssert(moc_); + return [NSEntityDescription insertNewObjectForEntityForName:@"DCTImageCacheItem" inManagedObjectContext:moc_]; +} + ++ (NSString*)entityName { + return @"DCTImageCacheItem"; +} + ++ (NSEntityDescription*)entityInManagedObjectContext:(NSManagedObjectContext*)moc_ { + NSParameterAssert(moc_); + return [NSEntityDescription entityForName:@"DCTImageCacheItem" inManagedObjectContext:moc_]; +} + +- (_DCTImageCacheItemID*)objectID { + return (_DCTImageCacheItemID*)[super objectID]; +} + ++ (NSSet *)keyPathsForValuesAffectingValueForKey:(NSString *)key { + NSSet *keyPaths = [super keyPathsForValuesAffectingValueForKey:key]; + + + return keyPaths; +} + + + + +@dynamic imageData; + + + + + + +@dynamic key; + + + + + + +@dynamic sizeString; + + + + + + + + + + + +@end diff --git a/mogenerator.sh b/mogenerator.sh new file mode 100755 index 0000000..f4ac782 --- /dev/null +++ b/mogenerator.sh @@ -0,0 +1 @@ +mogenerator -m DCTImageCacheBundle/DCTImageCache.xcdatamodeld/DCTImageCache.xcdatamodel -M DCTImageCache -H DCTImageCache --template-var arc=true \ No newline at end of file