Best way to implement RKReachabilityObserver in RestKit

后端 未结 2 2053
执笔经年
执笔经年 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条回答
  •  旧时难觅i
    2020-12-25 10:50

    Here is some changes in RestKit 0.20 and later. The code of reachability block should looks like:

        RKObjectManager *manager = [RKObjectManager managerWithBaseURL:[RemoteTools serverUrl]];
    [manager.HTTPClient setReachabilityStatusChangeBlock:^(AFNetworkReachabilityStatus status) {
        if (status == AFNetworkReachabilityStatusNotReachable) {
            UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"No network connection"
                                                            message:@"You must be connected to the internet to use this app."
                                                           delegate:nil
                                                  cancelButtonTitle:@"OK"
                                                  otherButtonTitles:nil];
            [alert show];
        }
    }];
    

提交回复
热议问题