Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add getters for properties

  • Loading branch information...
commit 9d635b1d51cbcb88138d96603ad93bb3c38499de 1 parent 410888c
@danielctull authored
View
5 DCTImageCache/DCTImageCacheAttributes.h
@@ -18,6 +18,11 @@ extern NSString *const DCTImageCacheAttributesCreatedBefore;
- (id)initWithDictionary:(NSDictionary *)dictionary;
@property (nonatomic, readonly, copy) NSDictionary *dictionary;
+
+@property (nonatomic, readonly) NSString *key;
+@property (nonatomic, readonly) NSDate *createdBefore;
+@property (nonatomic, readonly) CGSize size;
+
@property (nonatomic, readonly) NSString *identifier;
@end
View
22 DCTImageCache/DCTImageCacheAttributes.m
@@ -31,9 +31,9 @@ - (NSString *)description {
return [NSString stringWithFormat:@"<%@: %p; key = %@; size = %@; createdBefore = %@>",
NSStringFromClass([self class]),
self,
- [self _key],
+ self.key,
[self _sizeString],
- [self _createdBefore]];
+ self.createdBefore];
}
- (NSFetchRequest *)_fetchRequest {
@@ -42,7 +42,7 @@ - (NSFetchRequest *)_fetchRequest {
NSMutableArray *predicates = [[NSMutableArray alloc] initWithCapacity:3];
- NSString *key = [self _key];
+ NSString *key = self.key;
if (key.length > 0) {
NSPredicate *keyPredicate = [NSPredicate predicateWithFormat:@"%K == %@", _DCTImageCacheItemAttributes.key, key];
[predicates addObject:keyPredicate];
@@ -54,7 +54,7 @@ - (NSFetchRequest *)_fetchRequest {
[predicates addObject:sizePredicate];
}
- NSDate *createdBefore = [self _createdBefore];
+ NSDate *createdBefore = self.createdBefore;
if (createdBefore) {
NSPredicate *datePredicate = [NSPredicate predicateWithFormat:@"%K < %@", _DCTImageCacheItemAttributes.date, createdBefore];
[predicates addObject:datePredicate];
@@ -65,21 +65,27 @@ - (NSFetchRequest *)_fetchRequest {
}
- (void)_setupCacheItemProperties:(_DCTImageCacheItem *)cacheItem {
- cacheItem.key = [self _key];
+ cacheItem.key = self.key;
cacheItem.sizeString = [self _sizeString];
}
- (NSString *)_sizeString {
NSValue *value = [self.dictionary objectForKey:DCTImageCacheAttributesSize];
- if (!value) return nil;
+ if (!value) return @"";
return NSStringFromCGSize([value CGSizeValue]);
}
-- (NSString *)_key {
+- (CGSize)size {
+ NSValue *value = [self.dictionary objectForKey:DCTImageCacheAttributesSize];
+ if (!value) return DCTImageCacheAttributesNullSize;
+ return [value CGSizeValue];
+}
+
+- (NSString *)key {
return [self.dictionary objectForKey:DCTImageCacheAttributesKey];
}
-- (NSDate *)_createdBefore {
+- (NSDate *)createdBefore {
return [self.dictionary objectForKey:DCTImageCacheAttributesCreatedBefore];
}
Please sign in to comment.
Something went wrong with that request. Please try again.