2012-01-05 17 views
0

我的应用程序需要一个用户名和密码字段。在第一次登录验证工作完美。但第二次以后,密码字段中没有验证。它从缓存中自动收集。 我正在使用下面的代码进行请求。如何管理iPhone中的缓存代码

NSMutableURLRequest *theRequest = [NSMutableURLRequest requestWithURL:        [NSURL URLWithString:xmlUrl]          cachePolicy:NSURLRequestUseProtocolCachePolicy 
        timeoutInterval:30.0]; 

[theRequest setHTTPMethod:@“GET”]; NSURLResponse * response = nil;

[NSURLConnection sendSynchronousRequest:theRequest 
             returningResponse:&response error:&error]; 
NSDictionary* dict=[theRequest allHTTPHeaderFields]; 

在此先感谢

回答

0

只要使用此行:

NSMutableURLRequest *theRequest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:xmlUrl] 
              cachePolicy:NSURLRequestReloadIgnoringCacheData 
              timeoutInterval:30.0]; 
[theRequest setHTTPMethod:@"GET"]; 
+0

是....我想这个代码also.But还是现在同样的问题shows.Can你给我任何其他建议。在注销页面中,我使用了下面的代码。 [[NSURLCache sharedURLCache] removeAllCachedResponses]; – 2012-01-05 02:52:16

+0

对于请求中,我使用下面 \t NSMutableURLRequest * theRequest = [NSMutableURLRequest requestWithURL此多码:\t \t \t \t \t \t \t [NSURL URLWithString:XMLURL] \t \t \t \t \t \t \t \t \t \t的CachePolicy:NSURLRequestUseProtocolCachePolicy \t \t \t \t \t \t timeoutInterval:30.0]; [theRequest setHTTPMethod:@“GET”]; NSURLResponse * response = nil; \t [NSURLConnection的sendSynchronousRequest:theRequest \t \t \t \t \t \t \t \t \t \t returningResponse:响应误差:&错误]; \t NSDictionary * dict = [theRequest allHTTPHeaderFields]; – 2012-01-05 03:47:54