How to get change in network connection notification from iOS Reachability Class?

后端 未结 5 1994
没有蜡笔的小新
没有蜡笔的小新 2020-12-09 05:24

Hi I want to capture whenever user gets a network connectivity in my application for this I have added apples Reachability class and below is the snippet I am using in my ap

5条回答
  •  情深已故
    2020-12-09 06:22

    Maybe you should add the observer before startnotifier

    [[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(handleNetworkChange:) name: kReachabilityChangedNotification object: nil];
    reachability = [Reachability reachabilityForInternetConnection];
    [reachability startNotifier];
    

提交回复
热议问题