I changed the didFindService function as follows (my application is based on the Apple example "BonjourWeb"):
- (void)netServiceBrowser:(NSNetServiceBrowser*)netServiceBrowser didFindService:(NSNetService*)service moreComing:(BOOL)moreComing { [self.services addObject:service]; NSInteger i,n = [self.services count]; for(i=0;i<n;i++) { NSLog(@"%d %@",i,[[self.services objectAtIndex:i]name]); if (self.currentResolve) { [self stopCurrentResolve]; } self.currentResolve = [self.services objectAtIndex:i]; [self.currentResolve setDelegate:self]; [self.currentResolve resolveWithTimeout:0.0]; self.timer = [NSTimer scheduledTimerWithTimeInterval:20.0 target:self selector:@selector(showWaiting:) userInfo:self.currentResolve repeats:NO]; } if (!moreComing) { [self sortAndUpdateUI]; } }
I noticed that when starting my application, the netServiceDidResolveAddress function is called once and only allows the last element of the self.services array (I have 11 services, it only solves the object with index 10). My problem is to allow all services.
source share