Created
December 15, 2010 23:11
-
-
Save shnhrrsn/742758 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
#import "EGOCache.h" | |
@interface EGOCache (NSArray) | |
- (void)setArray:(NSArray*)array forKey:(NSString*)key; | |
- (void)setArray:(NSArray*)array forKey:(NSString*)key withTimeoutInterval:(NSTimeInterval)timeoutInterval; | |
- (NSArray*)arrayForKey:(NSString*)key; | |
@end |
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
#import "EGOCache+NSArray.h" | |
@implementation EGOCache (NSArray) | |
- (void)setArray:(NSArray*)array forKey:(NSString*)key { | |
[self setArray:array forKey:key withTimeoutInterval:self.defaultTimeoutInterval]; | |
} | |
- (void)setArray:(NSArray*)array forKey:(NSString*)key withTimeoutInterval:(NSTimeInterval)timeoutInterval { | |
[self setData:[NSKeyedArchiver archivedDataWithRootObject:array] forKey:key withTimeoutInterval:timeoutInterval]; | |
} | |
- (NSArray*)arrayForKey:(NSString*)key { | |
NSData* data = [self dataForKey:key]; | |
if(data) { | |
return [NSKeyedUnarchiver unarchiveObjectWithData:data]; | |
} else { | |
return nil; | |
} | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment