すべてのアプリケーションがフォアグラウンドに入るようにアプリケーションを設定しました。ウェブサーバーから情報を呼び出し、JSONを受け取ってパーズしてからオフラインで保存するWebコールを行います。iPhoneのビューがウェブコール後にリフレッシュされない
私のアプリケーションはタブ付きアプリケーションで、各画面はJSONから設定され、画像もサーバーから取得されます。ですから、各ページの情報を更新してから、更新しないようにします。
私は時間の間、シミュレータからアプリケーションを実行していますが、違いがあります。現在私が更新する情報を得ることができる唯一の方法は、そのviewDidAppearを使うか、xCodeからアプリケーションをやり直して起動することです。
は私がAppDelegates- (void)applicationWillEnterForeground:(UIApplication *)application
{
/*
Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
*/
WebCalls *wc = [[WebCalls alloc] init];
DashboardVC *db = [[DashboardVC alloc] init];
[wc setWebCallDidFinish:^(NSString * json, NSString *ID) {
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *docDir = [paths objectAtIndex: 0];
NSString *docFile = [docDir stringByAppendingPathComponent: @"json.txt"];
[json writeToFile:docFile atomically:NO encoding:NSUTF8StringEncoding error:Nil];
NSString *docDir2 = [paths objectAtIndex: 0];
NSString *docFile2 = [docDir2 stringByAppendingPathComponent: @"theID.txt"];
[ID writeToFile:docFile2 atomically:NO encoding:NSUTF8StringEncoding error:Nil];
[db testme];
}];
[wc getData];
}
これは、のviewDidLoadを再び呼び出してからクラスのviewDidLoadを呼び出すみましたが、情報は更新されません。なぜどんなアイデア?
編集:そのクラスでは、私はJSONをプリントアウトすることができます。この
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *docDir = [paths objectAtIndex: 0];
NSString *docFile = [docDir stringByAppendingPathComponent: @"json.txt"];
[json writeToFile:docFile atomically:NO encoding:NSUTF8StringEncoding error:Nil];
のようなJSONを読み込み、JSONは間違いなく更新されていますが、画面上の情報ではありません。
編集:ウェブコール
なぜウェブ通話コードを削除しましたか?それが重要かもしれないようです。それは非同期ですか? – Brian
ウェブコールは可能な限り非同期です。 wcはWebCallクラスのオブジェクトです。しかし、リフレッシュするコードは、Web呼び出しが終了した後に呼び出されるメソッド内にあります。 – AdamM
Web呼び出しコードを表示するように更新されました – AdamM