Permalink
Browse files

unarchiveObjectWithData raise exception for null data

Must change a little - (id<NSCoding>)objectForKey:(NSString*)key method because it raises an exception if the cache is empty for a key
  • Loading branch information...
1 parent 4580b2d commit b88e5570ebaf94c18b3518186061202f019826e0 @jfradj jfradj committed Jul 20, 2011
Showing with 5 additions and 1 deletion.
  1. +5 −1 EGOCache.m
View
@@ -279,7 +279,11 @@ - (void)setPlist:(id)plistObject forKey:(NSString*)key withTimeoutInterval:(NSTi
#pragma mark Object methods
- (id<NSCoding>)objectForKey:(NSString*)key {
- return [NSKeyedUnarchiver unarchiveObjectWithData:[self dataForKey:key]];
+ if([self hasCacheForKey:key]) {
+ return [NSKeyedUnarchiver unarchiveObjectWithData:[self dataForKey:key]];
+ } else {
+ return nil;
+ }
}
- (void)setObject:(id<NSCoding>)anObject forKey:(NSString*)key {

0 comments on commit b88e557

Please sign in to comment.