本地缓存的使用方法

NSURLCache *cache = [NSURLCache sharedURLCache];
    cache.memoryCapacity = 2 * 1024 * 1024;
    cache.diskCapacity = 20 * 1024 *1024;
    NSCachedURLResponse *response = [cache cachedResponseForRequest:request];
    
    if (response) {
//        NSLog(@"data:%@", response.data);
        id cacheResult = [NSJSONSerialization JSONObjectWithData:response.data options:NSJSONReadingMutableContainers error:nil];
        NSLog(@"cacheResult: %@", cacheResult);
    }

posted @ 2015-09-30 15:36  木子东晓东  阅读(273)  评论(0编辑  收藏  举报