What happens to SDWebImage Cached Images in my app when the image file on the server changes?

后端 未结 10 1245
夕颜
夕颜 2020-12-07 09:57

I am using the SDWebImage library to cache web images in my app:

https://github.com/rs/SDWebImage/blob/master/README.md

Current Usage:



        
10条回答
  •  我在风中等你
    2020-12-07 10:21

        NSURL *imageUrl = nil;
        NSDate *lastUpdate = [[NSUserDefaults standardUserDefaults] objectForKey:@"lastUpdate"];
        NSDate *currentDate = [NSDate date];
    
        if (lastUpdate == nil 
            || ![lastUpdate isKindOfClass:[NSDate class]] 
            || [currentDate timeIntervalSinceDate:lastUpdate] > 60 * 60 *24) {
                [[NSUserDefaults standardUserDefaults] setObject:currentDate forKey:@"lastUpdate"];
                NSString *urlString = [NSString stringWithFormat:@"http://yourdomain.com/image/image.png?%f", [currentDate timeIntervalSince1970]];
                imageUrl = [NSURL URLWithString:urlString];
        }
    

提交回复
热议问题