[英]NSNotificationCenter 'selector' working more than once is single Network status change
在我的應用程序中,我想檢測網絡狀態更改,以便在那時執行某些操作。 我在app-delegate中添加了以下代碼。 當我打開網絡連接“ networkStatusChanged:
”方法調用一次是正確的。 當我關閉網絡連接時,它會調用兩次。 請有人幫我解決問題......
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(networkStatusChanged:)
name:kReachabilityChangedNotification
object:nil];
reachability = [[Reachability reachabilityForInternetConnection] retain];
[reachability startNotifier];
它可能是為丟失的WiFi連接做了一次,對於丟失的小區數據連接是第二次。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.