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

problem while unarchive cached object #29

Open
driventokill opened this issue Feb 19, 2013 · 2 comments
Open

problem while unarchive cached object #29

driventokill opened this issue Feb 19, 2013 · 2 comments

Comments

@driventokill
Copy link

line 289 in EGOCache.m method - (UIImage*)imageForKey:(NSString*)key.
[NSKeyedUnarchiver unarchiveObjectWithFile:cachePathForKey(_directory, key)] return nil and throw a exception:
*** -[NSKeyedUnarchiver initForReadingWithData:]: incomprehensible archive (0xffffffff, 0xffffffd8, 0xffffffff, 0xffffffe0, 0x0, 0x10, 0x4a, 0x46)
Does anyone else have this problem? I got this problem while using EGOImageLoading.

@wingyiu
Copy link

wingyiu commented Apr 20, 2013

i think NSKeyedUnarchiver cannot read content data of image file.

#if TARGET_OS_IPHONE

  • (UIImage_)imageForKey:(NSString_)key {
    UIImage* image = nil;

    @Try {
    image=[[[UIImage alloc]initWithContentsOfFile:cachePathForKey(_directory, key)]autorelease];
    //image = [NSKeyedUnarchiver unarchiveObjectWithFile:cachePathForKey(_directory, key)];
    } @catch (NSException* e) {
    // Surpress any unarchiving exceptions and continue with nil
    }

    return image;
    }

@alexmcarthur
Copy link

You are correct - it may be better to change EGOImageLoader.m to archive the image via setImage:

  • (void)imageLoadConnectionDidFinishLoading:(EGOImageLoadConnection *)connection {
    ...
    } else {
    // [[EGOCache currentCache] setData:connection.responseData forKey:keyForURL(connection.imageURL,nil) withTimeoutInterval:604800];

    [[EGOCache currentCache] setImage:anImage forKey:keyForURL(connection.imageURL,nil) withTimeoutInterval:604800];
    

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

3 participants