如何使用代码管理iphone中的缓存
我的应用程序需要用户名和密码字段。第一次登录时,验证工作正常。但第二次登录后,密码字段中没有验证。它会自动从缓存中收集。 我正在使用以下代码进行请求如何使用代码管理iphone中的缓存,iphone,Iphone,我的应用程序需要用户名和密码字段。第一次登录时,验证工作正常。但第二次登录后,密码字段中没有验证。它会自动从缓存中收集。 我正在使用以下代码进行请求 NSMutableURLRequest *theRequest = [NSMutableURLRequest requestWithURL: [NSURL URLWithString:xmlUrl] cachePolicy
NSMutableURLRequest *theRequest = [NSMutableURLRequest requestWithURL: [NSURL URLWithString:xmlUrl] cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:30.0];
[TheRequestSetHttpMethod:@“获取”];
NSURLResponse*response=nil
[NSURLConnection sendSynchronousRequest:theRequest
returningResponse:&response error:&error];
NSDictionary* dict=[theRequest allHTTPHeaderFields];
提前感谢只需使用这一行即可:
NSMutableURLRequest *theRequest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:xmlUrl]
cachePolicy:NSURLRequestReloadIgnoringCacheData
timeoutInterval:30.0];
[theRequest setHTTPMethod:@"GET"];
是的……我也试过这个代码。但是现在还是一样的问题。你能给我其他的建议吗。在注销页面中,我使用了以下代码。[[NSURLCache sharedURLCache]移除所有缓存响应];对于请求,我在NSMutableUrlRequestTheRequest=[NSMutableUrlRequestRequestWithURL:[NSURL URLWithString:xmlUrl]cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:30.0]下面使用了这么多代码;[TheRequestSetHttpMethod:@“获取”];NSURL响应=零;[NSURLConnection sendSynchronousRequest:theRequest returningResponse:&响应错误:&错误];NSDictionary*dict=[theRequest allHTTPHeaderFields];