开发者

Iphone Caching Problem

when I call

-(IBAction)goback:(id)sender
{
    NSURL *xmlURL=[NSURL URLWithString:@"http://demo.komexa.com/sicherungsbereich.xml"];
    NSURLRequest *request = [NSURLRequest requestWithURL:xmlURL cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:2];
    NSURLResponse *theResponse;
    NSError *theError;
    NSData *myRequestResult = [NSURLConnection sendSynchronousRequest:request returningResponse:&theResponse error:&theError];
开发者_StackOverflow中文版    NSString *stringReply = (NSString *)[[NSString alloc] initWithData:myRequestResult encoding:NSUTF8StringEncoding];
    NSLog(@"reply from server: %@", stringReply);
}

with the Iphone , on the simulator it loads the String everytime really from the internet.But on the devices, it caches the String, so even if the content of http://demo.komexa.com/sicherungsbereich.xml changes (you can do that by calling http://demo.komexa.com) the String does not automatically reload new data.

Have you got an Idea?

I have uploaded the Code here,because of formatting problems: http://demo.komexa.com/problem.txt


just generate a random number and pass with your url , you get required result

e.g:

int randomNumber1 = 1 + arc4random()% 9; NSString *rstr = [NSString stringWithFormat: @"%d",randomNumber1];

NSString *address = @"http://www.socialfactory.net/client-app/photovote/get_data.php";
NSString * nstr=[NSString stringWithFormat:@"%@?t=%@",address,rstr];
//NSURLRequest *theRequest=nil;
NSURLRequest *  theRequest = [NSURLRequest requestWithURL:[NSURL URLWithString:nstr]];
NSURLResponse *resp = nil;
NSError *err = nil;


Maybe your Simulator and iPhone have different proxie settings. check this or try with the NSURLRequestReloadIgnoringLocalAndRemoteCacheData policy which also ignores intermediate cachings. See the docs here.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜