数か月ごとに更新されるPDFをダウンロードするアプリがあり、特定のPDFをダウンロードするたびに、1文字を含む.txtファイルもダウンロードします。更新されたPDFをサーバーにアップロードするたびに、サーバーの.txtファイルに文字数を1つずつ作成します。
ユーザーがアプリの[更新]ボタンをタップすると、サーバーからの.txtファイルの文字列とローカルの.txtファイルの文字列が比較されます。
これは、新しいPDFが利用可能かどうかを確認するための非常に軽量な方法ですが、自分のPDFファイルごとに.txtファイルを作成せずに、これを行うためのより良い方法またはより軽い方法があるかどうかを尋ねています。サーバ?
助けを提供してくれてありがとう!
これは、新しいPDFをチェックするために使用するコードです。
NSString *documentDirectory = [(AppDelegate *)[[UIApplication sharedApplication] delegate] applicationDocumentsDirectory];
NSString *path = [documentDirectory stringByAppendingPathComponent:@"test.txt"];
NSString *server = [NSString stringWithContentsOfURL:[NSURL URLWithString:@"foo.com/test.txt"] encoding:NSASCIIStringEncoding error:nil];
NSString *local = [NSString stringWithContentsOfFile:path encoding:NSASCIIStringEncoding error:nil];
if(![local isEqualToString:server])
{
// I Download the new PDF and the new .txt file here;
// simple NSURLConnection stuff, no need to elaborate
}