就是写进文件,然后判断是否存在来发起请求或者加载本地文件
代码片段
NSString * htmlResponseStr=[NSString stringWithContentsOfURL:[NSURL URLWithString:urlStr] encoding:NSUTF8StringEncoding error:Nil];
    NSString *resourcePath = [ [NSBundle mainBundle] resourcePath];
    [_fileManager createDirectoryAtPath:[resourcePath stringByAppendingString:@"/Caches"] withIntermediateDirectories:YES attributes:nil error:nil];
    NSString * path=[resourcePath stringByAppendingString:[NSString stringWithFormat:@"/Caches/%d.html",[urlStr hash]]];
    [htmlResponseStr writeToFile:path atomically:YES encoding:NSUTF8StringEncoding error:nil];

 
posted on 2015-08-11 16:30  火星的蝈蝈  阅读(181)  评论(0编辑  收藏  举报