Permalink
Browse files

now requiring extension for externalstorage

  • Loading branch information...
1 parent 8b9db9c commit d9d632d9b7f072ab3b1ad069ace8ac0e9557e638 @drewcrawford committed Apr 23, 2013
@@ -17,5 +17,5 @@
You can then restore by running [[objectFuture key] contentsOfFile]
*/
-- (void)setCacheFileWithData:(NSData *)data forKey :(NSString *)key;
+- (void)setCacheFileWithData:(NSData *)data forKey :(NSString *)key usingExtension:(NSString*) extension;
@end
@@ -9,13 +9,13 @@
#import "NSManagedObject+ExternalStorage.h"
#import <DCAKit/NSError+LessTerrible.h>
@implementation NSManagedObject (ExternalStorage)
-- (void)setCacheFileWithData:(NSData *)data forKey :(NSString *)key {
+- (void)setCacheFileWithData:(NSData *)data forKey :(NSString *)key usingExtension:(NSString *)extension {
CFUUIDRef uniqueID = CFUUIDCreate(NULL);
NSString *uniqueFilename = (__bridge_transfer NSString*)CFUUIDCreateString(NULL, uniqueID);
CFRelease(uniqueID);
NSArray* cachePathArray = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
NSString *cacheDir = cachePathArray[0];
- NSString *filePath = [cacheDir stringByAppendingPathComponent:uniqueFilename];
+ NSString *filePath = [[cacheDir stringByAppendingPathComponent:uniqueFilename] stringByAppendingPathExtension:extension];
NSError *err = nil;
if (![data writeToFile:filePath options:0 error:&err]) {
[err present];

0 comments on commit d9d632d

Please sign in to comment.