# HG changeset patch # User Jens Alfke # Date 1242508215 25200 # Node ID 60f2b46d9a3bbd841e1860b859d811d0e8892d2c # Parent 50dc5502ef469f42884b1e7c4147b413bb433cd8 * Fixed #9: compilation error with iPhone 3.0 SDK. * MYBonjourRegistration now allows you to set a TXT dictionary with non-NSData key values; they'll be translated to UTF-8 object descriptions. Useful for NSStrings and NSNumbers. diff -r 50dc5502ef46 -r 60f2b46d9a3b Bonjour/MYBonjourRegistration.m --- a/Bonjour/MYBonjourRegistration.m Sun May 10 19:05:52 2009 -0700 +++ b/Bonjour/MYBonjourRegistration.m Sat May 16 14:10:15 2009 -0700 @@ -148,10 +148,24 @@ } ++ (NSData*) dataFromTXTRecordDictionary: (NSDictionary*)txtDict { + // First translate any non-NSData values into UTF-8 formatted description data: + NSMutableDictionary *encodedDict = $mdict(); + for (NSString *key in txtDict) { + id value = [txtDict objectForKey: key]; + if (![value isKindOfClass: [NSData class]]) { + value = [[value description] dataUsingEncoding: NSUTF8StringEncoding]; + } + [encodedDict setObject: value forKey: key]; + } + return [NSNetService dataFromTXTRecordDictionary: encodedDict]; +} + + - (void) updateTxtRecord { [NSObject cancelPreviousPerformRequestsWithTarget: self selector: @selector(updateTxtRecord) object: nil]; if (self.serviceRef) { - NSData *data = [NSNetService dataFromTXTRecordDictionary: _txtRecord]; + NSData *data = [[self class] dataFromTXTRecordDictionary: _txtRecord]; Assert(data!=nil, @"Can't convert dictionary to TXT record"); DNSServiceErrorType err = DNSServiceUpdateRecord(self.serviceRef, NULL, diff -r 50dc5502ef46 -r 60f2b46d9a3b MYNetwork-iPhone.xcodeproj/project.pbxproj --- a/MYNetwork-iPhone.xcodeproj/project.pbxproj Sun May 10 19:05:52 2009 -0700 +++ b/MYNetwork-iPhone.xcodeproj/project.pbxproj Sat May 16 14:10:15 2009 -0700 @@ -218,8 +218,8 @@ isa = PBXGroup; children = ( 27D915B90FA8EA85002B0DEC /* Addressing */, + 278C1B2A0F9F865800954AE1 /* PortMapper */, 27D915BA0FA8EA98002B0DEC /* Bonjour */, - 278C1B2A0F9F865800954AE1 /* PortMapper */, 270E9AA30EE61113003F17CA /* TCP */, 270E9AAF0EE61113003F17CA /* BLIP */, ); diff -r 50dc5502ef46 -r 60f2b46d9a3b TCP/TCPConnection.m --- a/TCP/TCPConnection.m Sun May 10 19:05:52 2009 -0700 +++ b/TCP/TCPConnection.m Sat May 16 14:10:15 2009 -0700 @@ -150,9 +150,11 @@ } -@synthesize address=_address, isIncoming=_isIncoming, status=_status, delegate=_delegate, +@synthesize address=_address, isIncoming=_isIncoming, status=_status, reader=_reader, writer=_writer, server=_server, openTimeout=_openTimeout; +- (id) delegate {return _delegate;} +- (void) setDelegate: (id) delegate {_delegate = delegate;} - (NSError*) error { diff -r 50dc5502ef46 -r 60f2b46d9a3b TCP/TCPListener.m --- a/TCP/TCPListener.m Sun May 10 19:05:52 2009 -0700 +++ b/TCP/TCPListener.m Sat May 16 14:10:15 2009 -0700 @@ -52,13 +52,17 @@ } -@synthesize delegate=_delegate, port=_port, useIPv6=_useIPv6, +@synthesize port=_port, useIPv6=_useIPv6, bonjourServiceType=_bonjourServiceType, bonjourServiceOptions=_bonjourServiceOptions, bonjourPublished=_bonjourPublished, bonjourError=_bonjourError, bonjourService=_netService, pickAvailablePort=_pickAvailablePort; +- (id) delegate {return _delegate;} +- (void) setDelegate: (id) delegate {_delegate = delegate;} + + - (NSString*) description { return $sprintf(@"%@[port %hu]",self.class,_port);