iosbonjournsnetservice

Updating TXTRecordDictionary doesn't always notify monitoring services


I'm using bonjour to find other devices. Each device uses TXTRecordData to share its name:

NSDictionary* dictionary = @{ @"name": @"Goose" };
[service setTXTRecordData:[NSNetService dataFromTXTRecordDictionary:dictionary]];

Each device listens for changes:

- (void) netService:(NSNetService *)sender didUpdateTXTRecordData:(NSData *)data
{
    ...
}

About 80% of the time it works - didUpdateTXTRecordData is called when a name is changed.

Sometimes the other devices are never notified.

I've checked and setTXTRecordData returns YES when the data is lost.

How can I make sure updates to the TXTRecordData makes it to other devices?


Solution

  • Someone posted a gist demonstrating what is possibly the above bug.

    For you Apple people out there, the gist says the relevant rdar is rdar://11018654