I set this from two different methods:

[[AFNetworkReachabilityManager sharedManager] startMonitoring];
                [[AFNetworkReachabilityManager sharedManager] setReachabilityStatusChangeBlock:^(AFNetworkReachabilityStatus status) {
                    if(status == AFNetworkReachabilityStatusNotReachable ||
                       status == AFNetworkReachabilityStatusUnknown){
                        self.liveTimesBar.hidden = YES;

                        //In case we regain connection
                        [[AFNetworkReachabilityManager sharedManager] startMonitoring];
                        [[AFNetworkReachabilityManager sharedManager] setReachabilityStatusChangeBlock:^(AFNetworkReachabilityStatus status) {
                            if(status == AFNetworkReachabilityStatusReachableViaWWAN ||
                               status == AFNetworkReachabilityStatusReachableViaWiFi){
                                [self extractedRelevantFlightNumbers];
                            }
                        }];
                    }
                }];

So my idea is, that when we lose Internet, that this liveTimesBar gets hidden. But at the same time register for notifications, if we regain internet again. And I do this from two different methods for different stuff.

So my questions:

  1. If one of these blocks gets executed, is it then "done" or will it be again executed if this event happens? Or is it just set for one connectivity change?

  2. If I register from two different methods for this notification, will they both executed?

1 Answers

1
amar On Best Solutions

Shared Manager refers to a singleton instance and unless the setReachabilityStatusChangeBlock pushes the code block in some array and while calling iterates over array and calls each stored block(which is not the case). Blocks will be stored in one variable and like all variable, it will save the last update. So you can safely expect your latest block which you have passed to be called.