Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cache verify #47

Open
narlei opened this issue Feb 2, 2015 · 1 comment
Open

Cache verify #47

narlei opened this issue Feb 2, 2015 · 1 comment

Comments

@narlei
Copy link

narlei commented Feb 2, 2015

Hello,

In my project I add the block in - (UIImage_)imageForKey:(NSString_)key { :
if (!image && pathImage){
@Try {
NSData *data = [NSData dataWithContentsOfFile:pathImage];
image = [UIImage imageWithData:data];
} @catch (NSException *e1) {

        }
    }

if not success "[NSKeyedUnarchiver unarchiveObjectWithFile:pathImage]", then verify if can transform the data file in UIImage;

It's working very fine.

Can you add this in the project? Because I'm using cocoaPods in my project.

Thank you! This Class is wonderful.

  • (UIImage_)imageForKey:(NSString_)key {
    UIImage* image = nil;
    NSString _pathImage = nil;
    @Try {
    pathImage = cachePathForKey(directory, key);
    image = [NSKeyedUnarchiver unarchiveObjectWithFile:pathImage];
    } @catch (NSException
    e) {
    // Surpress any unarchiving exceptions and continue with nil
    if (!image && pathImage){
    @Try {
    NSData *data = [NSData dataWithContentsOfFile:pathImage];
    image = [UIImage imageWithData:data];
    } @catch (NSException *e1) {

        }
    }
    

    }

    return image;
    }

@narlei
Copy link
Author

narlei commented Jan 17, 2017

Created a pull request #59

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant