美文网首页
ios wkwebview 清除缓存

ios wkwebview 清除缓存

作者: J_HX | 来源:发表于2018-02-12 17:37 被阅读693次

    if ([[[UIDevice currentDevice]systemVersion]intValue ] >8) {
    NSArray * types =@[WKWebsiteDataTypeMemoryCache,WKWebsiteDataTypeDiskCache]; // 9.0之后才有的
    NSSet *websiteDataTypes = [NSSet setWithArray:types];
    NSDate *dateFrom = [NSDate dateWithTimeIntervalSince1970:0];

        [[WKWebsiteDataStore defaultDataStore] removeDataOfTypes:websiteDataTypes modifiedSince: dateFrom completionHandler:^{
        
        }];
    }else{
        NSString *libraryPath = [NSSearchPathForDirectoriesInDomains(NSLibraryDirectory,NSUserDomainMask,YES) objectAtIndex:0];
        
        NSString *cookiesFolderPath = [libraryPath stringByAppendingString:@"/Cookies"];
    
        NSError *errors;
        [[NSFileManager defaultManager] removeItemAtPath:cookiesFolderPath error:&errors];
    }
    

    相关文章

      网友评论

          本文标题:ios wkwebview 清除缓存

          本文链接:https://www.haomeiwen.com/subject/wuqdtftx.html