Bonjour/MYBonjourService.m
changeset 43 aab592ac36fc
parent 31 1d6924779df7
child 44 d8a559a39284
     1.1 --- a/Bonjour/MYBonjourService.m	Wed Apr 29 13:29:31 2009 -0700
     1.2 +++ b/Bonjour/MYBonjourService.m	Tue May 05 23:24:50 2009 -0700
     1.3 @@ -232,8 +232,7 @@
     1.4                               &resolveCallback, self);
     1.5  }
     1.6  
     1.7 -
     1.8 -- (MYAddressLookup*) addressLookup {
     1.9 +- (MYAddressLookup*) addressLookupObservingNewAddresses:(NSObject *)observer {
    1.10      if (!_addressLookup) {
    1.11          // Create the lookup the first time this is called:
    1.12          _addressLookup = [[MYAddressLookup alloc] initWithHostname: self.hostname];
    1.13 @@ -241,10 +240,17 @@
    1.14          _addressLookup.interfaceIndex = _interfaceIndex;
    1.15      }
    1.16      // (Re)start the lookup if it's expired:
    1.17 -    if (_addressLookup && _addressLookup.timeToLive <= 0.0)
    1.18 +    if (_addressLookup && _addressLookup.timeToLive <= 0.0) {
    1.19 +		if (observer != nil) {
    1.20 +			[_addressLookup addObserver:observer forKeyPath:@"addresses" options:NSKeyValueObservingOptionNew context:NULL];
    1.21 +		}
    1.22          [_addressLookup start];
    1.23 +	}
    1.24      return _addressLookup;
    1.25  }
    1.26 +- (MYAddressLookup*) addressLookup {
    1.27 +	return [self addressLookupObservingNewAddresses:nil];
    1.28 +}
    1.29  
    1.30  
    1.31  - (MYBonjourQuery*) queryForRecord: (UInt16)recordType {