1.1 --- a/Bonjour/MYAddressLookup.m Wed Apr 29 13:29:31 2009 -0700
1.2 +++ b/Bonjour/MYAddressLookup.m Wed May 06 09:21:57 2009 -0700
1.3 @@ -25,7 +25,7 @@
1.4 return nil;
1.5 }
1.6 _hostname = [hostname copy];
1.7 - _addresses = [[NSMutableArray alloc] init];
1.8 + _addresses = [[NSMutableSet alloc] init];
1.9 }
1.10 return self;
1.11 }
1.12 @@ -62,10 +62,24 @@
1.13 if (address) {
1.14 if (flags & kDNSServiceFlagsAdd) {
1.15 LogTo(DNS,@"%@ got %@ [TTL = %u]", self, address, ttl);
1.16 + NSSet *changedObjects = [NSSet setWithObject:address];
1.17 + [self willChangeValueForKey:@"addresses"
1.18 + withSetMutation:NSKeyValueUnionSetMutation
1.19 + usingObjects:changedObjects];
1.20 [_addresses addObject: address];
1.21 + [self didChangeValueForKey:@"addresses"
1.22 + withSetMutation:NSKeyValueUnionSetMutation
1.23 + usingObjects:changedObjects];
1.24 } else {
1.25 LogTo(DNS,@"%@ lost %@ [TTL = %u]", self, address, ttl);
1.26 + NSSet *changedObjects = [NSSet setWithObject:address];
1.27 + [self willChangeValueForKey:@"addresses"
1.28 + withSetMutation:NSKeyValueMinusSetMutation
1.29 + usingObjects:changedObjects];
1.30 [_addresses removeObject: address];
1.31 + [self didChangeValueForKey:@"addresses"
1.32 + withSetMutation:NSKeyValueMinusSetMutation
1.33 + usingObjects:changedObjects];
1.34 }
1.35 [address release];
1.36 }
1.37 @@ -96,7 +110,16 @@
1.38
1.39
1.40 - (DNSServiceErrorType) createServiceRef: (DNSServiceRef*)sdRefPtr {
1.41 - [_addresses removeAllObjects];
1.42 + if ([_addresses count] > 0) {
1.43 + NSSet *changedObjects = [NSSet setWithSet:_addresses];
1.44 + [self willChangeValueForKey:@"addresses"
1.45 + withSetMutation:NSKeyValueMinusSetMutation
1.46 + usingObjects:changedObjects];
1.47 + [_addresses removeAllObjects];
1.48 + [self didChangeValueForKey:@"addresses"
1.49 + withSetMutation:NSKeyValueMinusSetMutation
1.50 + usingObjects:changedObjects];
1.51 + }
1.52 return DNSServiceGetAddrInfo(sdRefPtr,
1.53 kDNSServiceFlagsShareConnection,
1.54 _interfaceIndex, 0,