views:

222

answers:

5

Hello, 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];
    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

A: 

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.

Kai
A: 

I have already tried this with: NSURLRequestReloadIgnoringLocalAndRemoteCacheData and i had the same problem.

Ploetzeneder
A: 

Does not work,any other ideas

Ploetzeneder
A: 

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;
Sajid Hussain
Yeah thats a idea, i have also done this in that way but that is not a good solution
Ploetzeneder
A: 

use my answer , i think it is good solution, i try all these methods, but does not work, so use random request adding method.

Sajid Hussain