2009-11-24 6 views
0
나는 그것이 장치에 internet.But에서 정말 문자열마다로드 시뮬레이터, 아이폰과

아이폰 캐싱 문제

-(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); 
} 

전화

, 그것은, 문자열을 캐시 그래서 경우에도 http://demo.komexa.com/sicherungsbereich.xml의 내용 변경 (당신은 http://demo.komexa.com를 호출하여 그렇게 할 수 있습니다) 문자열은 자동으로 새 데이터를 다시로드하지 않습니다.

아이디어가 있으십니까? 나는 때문에 형식의 문제, 여기에 코드를 업로드 한

는 : http://demo.komexa.com/problem.txt

+0

- (IBAction를)하고 GoBack (ID) 송신기 { NSURL xmlURL * = [NSURL URLWithString @ "http://demo.komexa.com/sicherungsbereich.xml"]; NSURLRequest * 요청 = [NSURLRequest requestWithURL : xmlURL cachePolicy : NSURLRequestReloadIgnoringCacheData timeoutInterval : 2]; NSURLResponse * theResponse; NSError * theError; NSData * myRequestResult = [NSURLConnection sendSynchronousRequest : requestResponse 요청 : & theResponse 오류 : & theError]; NSString * stringReply = (NSString *) [[NSString alloc] initWithData : myRequestResult 인코딩 : NSUTF8StringEncoding]; NSLog (@ "reply from server : % @", stringReply); } – Ploetzeneder

+0

코드 서식을 지정하려면 코드 블록을 선택하고 1과 0이있는 단추를 누르거나 각 코드 줄 앞에 4 칸을 둡니다. –

+0

오케이, 고마워. 다른 사람이 이것을 어떻게 얻을 수있는 아이디어가 있습니까? – Ploetzeneder

답변

1

그냥 임의의 숫자를 생성하고 URL을, 당신이 필요 얻을 결과 통과

예컨대 :

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; 
+0

그래, 그게 아이디어 야. 나도 그렇게 했어.하지만 그게 좋은 해결책이 아니야. – Ploetzeneder

1

은 어쩌면 당신의 시뮬레이터와 아이폰은 다른 proxie 설정이 있습니다. 이것을 확인하거나 중간 캐시를 무시하는 정책 인 NSURLRequestReloadIgnoringLocalAndRemoteCacheData으로 시도하십시오. See the docs here.

+0

Unforunately NSURLRequestReloadIgnoringLocalAndRemoteCacheData가 적어도 iOS v6의 경우 구현되지 않았습니다. –