Best way to implement RKReachabilityObserver in RestKit

后端 未结 2 2045
执笔经年
执笔经年 2020-12-25 10:21

I have written a tab based application in Xcode/RestKit and am attempting to use the RKReachabilityObserver to determine Internet connectivity on the device.

Ideally

2条回答
  •  生来不讨喜
    2020-12-25 11:02

    The [RKClient sharedClient] singleton already has a property for that (reachabilityObserver). Feel free to use that one.

    if ([[[RKClient sharedClient] reachabilityObserver] isReachabilityDetermined] && [[RKClient sharedClient] isNetworkReachable]) {
        ....
    }
    

    You can also subscribe to RKReachabilityObserver notifications (if you want to take any action when reachability status changes)

        [[NSNotificationCenter defaultCenter] addObserver:self 
                                                 selector:@selector(reachabilityStatusChanged:) 
                                                     name:RKReachabilityDidChangeNotification object:nil];
    

提交回复
热议问题