2012-04-23 9 views
0

私がホテルにいたとき、Wi-Fiは非常に遅いインターネット接続を介してインターネットに接続されていたようです。実際にはモデムに基づいている可能性があります。iOS:ネットワーク接続が遅いためにアプリケーションがSIGKILLを取得しますか?

私のアプリのHTTP GETリクエストにより、iOSが自分のアプリをSIGKILL(Xcodeが示すように)に送信したように見えます。

なぜですか?直し方?

ありがとうございました。

+0

HTTPリクエストを作成して処理するコードを表示する必要があります。質問を編集して貼り付けます。 –

答えて

1

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); 
} 
関連する問題