2009-12-14 3 views

ответ

4

Вы можете просто использовать таймер и отменить свой запрос на уведомление, если он не принят к тому времени?

например. принимая пример достижимости Apple:

- (void) startNotifier 
{ 
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onReachabilityChanged:) name:@"kNetworkReachabilityChangedNotification" object:nil]; 
    notified = NO; 
    [self performSelector:@selector(onRequestTimeout) withObject:nil afterDelay:5.0]; // 5 secs 
} 

- (void)onReachabilityChanged:(NSNotification *)note 
{ 
     // Do whatever on notification 
     notified = YES; 
} 

- (void) onRequestTimeout 
{ 
    if (!notified) 
    { 
     // Do whatever on request timeout 
     [[NSNotificationCenter defaultCenter] removeObserver:self name:@"kNetworkReachabilityChangedNotification" object:nil]; 
    } 
}