1.1 --- a/Bonjour/MYBonjourRegistration.m Sat May 16 14:10:15 2009 -0700
1.2 +++ b/Bonjour/MYBonjourRegistration.m Thu Jul 02 20:45:11 2009 -0700
1.3 @@ -60,6 +60,7 @@
1.4 [_name release];
1.5 [_type release];
1.6 [_domain release];
1.7 + [_txtRecord release];
1.8 [super dealloc];
1.9 }
1.10
1.11 @@ -149,6 +150,8 @@
1.12
1.13
1.14 + (NSData*) dataFromTXTRecordDictionary: (NSDictionary*)txtDict {
1.15 + if (!txtDict)
1.16 + return nil;
1.17 // First translate any non-NSData values into UTF-8 formatted description data:
1.18 NSMutableDictionary *encodedDict = $mdict();
1.19 for (NSString *key in txtDict) {
1.20 @@ -166,7 +169,7 @@
1.21 [NSObject cancelPreviousPerformRequestsWithTarget: self selector: @selector(updateTxtRecord) object: nil];
1.22 if (self.serviceRef) {
1.23 NSData *data = [[self class] dataFromTXTRecordDictionary: _txtRecord];
1.24 - Assert(data!=nil, @"Can't convert dictionary to TXT record");
1.25 + Assert(data!=nil || _txtRecord==nil, @"Can't convert dictionary to TXT record: %@", _txtRecord);
1.26 DNSServiceErrorType err = DNSServiceUpdateRecord(self.serviceRef,
1.27 NULL,
1.28 0,
1.29 @@ -187,10 +190,7 @@
1.30
1.31 - (void) setTxtRecord: (NSDictionary*)txtDict {
1.32 if (!$equal(_txtRecord,txtDict)) {
1.33 - if (txtDict)
1.34 - [_txtRecord setDictionary: txtDict];
1.35 - else
1.36 - setObj(&_txtRecord,nil);
1.37 + setObjCopy(&_txtRecord, txtDict);
1.38 [NSObject cancelPreviousPerformRequestsWithTarget: self selector: @selector(updateTxtRecord) object: nil];
1.39 [self performSelector: @selector(updateTxtRecord) withObject: nil afterDelay: 0.1];
1.40 }
1.41 @@ -235,6 +235,7 @@
1.42 - (void) updateTXT {
1.43 NSDictionary *txt = $dict({@"time", $sprintf(@"%.3lf", CFAbsoluteTimeGetCurrent())});
1.44 _reg.txtRecord = txt;
1.45 + CAssertEqual(_reg.txtRecord, txt);
1.46 [self performSelector: @selector(updateTXT) withObject: nil afterDelay: 3.0];
1.47 }
1.48