当前位置:   iOS > 正文

当我使用NSCachedURLResponse时,我得到了"301PermMove"

nsurlcache,ios,nscache,https,git,DevBox,在线流程图,编程,编程问答,程序员,开发者工具,开发工具,json解析,二维码生成,unix时间戳,在线开发工具,前端开发工具,开发人员工具,站长工具

当我测试时NSURLCache,我得到了"301PermMove",这是我的代码

-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{

NSURL *url = [NSURL URLWithString:@"https://www.github.com"];
NSURLRequest *urlRequest = [[NSURLRequest alloc]initWithURL:url cachePolicy:NSURLRequestReturnCacheDataElseLoad timeoutInterval:10];
NSURLCache *shareCache = [NSURLCache sharedURLCache];
NSCachedURLResponse *resp = [shareCache cachedResponseForRequest:urlRequest];
NSLog(@"cache data:%@",[[NSString alloc]initWithData:resp.data encoding:NSUTF8StringEncoding]);

[NSURLConnection sendAsynchronousRequest:urlRequest queue:[NSOperationQueue mainQueue] completionHandler:^(NSURLResponse * _Nullable response, NSData * _Nullable data, NSError * _Nullable connectionError) {

    NSLog(@"data:%@",[[NSString alloc]initWithData:data encoding:NSUTF8StringEncoding]);
}];
}

第一次触摸:缓存数据为零,第二次触摸:缓存数据为301PermMove.为什么?我不知道.

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/blog/iOS/detail/8301
推荐阅读
相关标签
  

闽ICP备14008679号