Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions EGOCache.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,11 @@
- (void)setPlist:(id)plistObject forKey:(NSString*)key;
- (void)setPlist:(id)plistObject forKey:(NSString*)key withTimeoutInterval:(NSTimeInterval)timeoutInterval;

- (id)jsonObjectForKey:(NSString*)key;
- (id)mutableJsonObjectForKey:(NSString*)key;
- (void)setJson:(id)jsonObject forKey:(NSString*)key;
- (void)setJson:(id)jsonObject forKey:(NSString*)key withTimeoutInterval:(NSTimeInterval)timeoutInterval;

- (void)copyFilePath:(NSString*)filePath asKey:(NSString*)key;
- (void)copyFilePath:(NSString*)filePath asKey:(NSString*)key withTimeoutInterval:(NSTimeInterval)timeoutInterval;

Expand Down
27 changes: 27 additions & 0 deletions EGOCache.m
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,33 @@ - (void)setPlist:(id)plistObject forKey:(NSString*)key withTimeoutInterval:(NSTi
[self setData:plistData forKey:key withTimeoutInterval:timeoutInterval];
}

#pragma mark -
#pragma mark JSON Object methods

- (id)jsonObjectForKey:(NSString*)key {
NSData* jsonData = [self dataForKey:key];

return [NSJSONSerialization JSONObjectWithData:jsonData options:NSJSONReadingAllowFragments error:nil];

}

- (id)mutableJsonObjectForKey:(NSString*)key {
NSData* jsonData = [self dataForKey:key];

return [NSJSONSerialization JSONObjectWithData:jsonData options:NSJSONReadingMutableContainers error:nil];

}

- (void)setJson:(id)jsonObject forKey:(NSString*)key {
[self setJson:jsonObject forKey:key withTimeoutInterval:self.defaultTimeoutInterval];
}

- (void)setJson:(id)jsonObject forKey:(NSString*)key withTimeoutInterval:(NSTimeInterval)timeoutInterval {
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:jsonObject options:0 error:nil];

[self setData:jsonData forKey:key withTimeoutInterval:timeoutInterval];
}

#pragma mark -
#pragma mark Object methods

Expand Down