私のコードは、Webサーバー上のXMLファイルからurlのコンテンツを書き込んでいます。その内容を文字列に格納し、それをドキュメントディレクトリのローカルファイルに書き込みます。私はこのビューを再度実行しても、常にデバイスにキャッシュされているコンテンツを取得し、Webサーバーからの更新はありません。stringWithContentsOfURLキャッシュを使用してURLコンテンツを文字列に書き込む
毎回サーバー上のファイルから内容を読み取る方法を教えてください。
NSString * path = @"http://my-domain-name.com/myGlobalFile.xml";
NSString * myStr = [NSString stringWithContentsOfURL:[NSURL URLWithString:path] encoding:NSUTF8StringEncoding error:nil];
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
localFilePath = [documentsDirectory stringByAppendingPathComponent:@"myLocalFile.xml"];
[myStr writeToFile:localFilePath atomically:YES encoding:NSUTF8StringEncoding error:nil];
ここでは、あなたのプログラムで上記のスニペットを行っていますか? writeToFileが返すことができるエラーオブジェクトをチェックすることもできます。 – onnoweb