LoginSignup
5
5

More than 5 years have passed since last update.

Reachabilityで通知が取れない場合

Posted at

Reachabilityを利用してWifiやインターネットの通信可能・不可能を取る事ができる。これの通知を取る事が出来なくて数時間を無駄にしてしまったので記す。

Reachability *internetReach = [Reachability reachabilityForInternetConnection];

のように作成したReachabilityのインスタンスは、インスタンス変数にしておく等してメモリ上に継続して保持していなければいけない。上記の用にローカル変数に確保したままにして保持しなかった場合、アプリが落ちるのではなく通知が来ないという結果になる。

こんな簡単な事に気づくのに時間がかかってしまった。

5
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
5