當我打電話iPhone緩存問題
-(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);
}
與iPhone,在模擬器上加載字符串每次真正從internet.But的設備上,它緩存的字符串,所以即使http://demo.komexa.com/sicherungsbereich.xml內容更改(您可以通過調用http://demo.komexa.com來實現),字符串不會自動重新加載新數據。
你有想法嗎?
我已經在這裏上傳,因爲格式問題的代碼,: http://demo.komexa.com/problem.txt
- (IBAction爲)GoBack的:(ID)發送方 { 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]; (@「從服務器回覆:%@」,stringReply); } – Ploetzeneder
要格式化代碼,只需選擇代碼塊並用1和0按鈕或在每行代碼前放4個空格。 –
好的,謝謝你的提示。有沒有人有另一種想法如何解決這個問題 – Ploetzeneder