iOS清除缓存

- (void)clearCacheClick
{
    [SVProgressHUD showWithStatus:@"clearing···"];
    [SVProgressHUD setDefaultMaskType:SVProgressHUDMaskTypeBlack];
    
    [[SDImageCache sharedImageCache] clearDiskOnCompletion:^{
        dispatch_async(dispatch_get_global_queue(0, 0), ^{
           
            [NSThread sleepForTimeInterval:2.0];
            
            NSFileManager *mgr = [NSFileManager defaultManager];
            [mgr removeItemAtPath:kFILECACHE_PATH error:nil];
            [mgr createDirectoryAtPath:kFILECACHE_PATH withIntermediateDirectories:YES attributes:nil error:nil];
            
            dispatch_async(dispatch_get_main_queue(), ^{
               
                [SVProgressHUD dismiss];
                
                // 设置文字
                self.detailTextLabel.text = nil;
                
            });
            
        });
    }];
}

你可能感兴趣的:(iOS清除缓存)