HTTPリクエストをバックグラウンドスレッドに配置する必要があります。メインスレッドが応答時間が長すぎる場合、アプリは終了します。
通常、Webサービス用のAPIは非同期フェッチを提供します。あなたはそれを使うべきです。
APIがそのような機能を提供していない場合は、別のAPIを使用してください。それを除いて、あなた自身のバックグラウンドに入れてください。何かのように
- (void)issuePotentiallyLongRequest
{
dispatch_queue_t q = dispatch_queue_create("my background q", 0);
dispatch_async(q, ^{
// The call to dispatch_async returns immediately to the calling thread.
// The code in this block right here will run in a different thread.
// Do whatever stuff you need to do that takes a long time...
// Issue your http get request or whatever.
[self.httpClient goFetchStuffFromTheInternet];
// Now, that code has run, and is done. You need to do something with the
// results, probably on the main thread
dispatch_async(dispatch_get_main_queue(), ^{
// Do whatever you want with the result. This block is
// now running in the main thread - you have access to all
// the UI elements...
// Do whatever you want with the results of the fetch.
[self.myView showTheCoolStuffIDownloadedFromTheInternet];
});
});
dispatch_release(q);
}
HTTPリクエストを作成して処理するコードを表示する必要があります。質問を編集して貼り付けます。 –