Joe,

You'll need to drop below NSNetService and CFNetService to manipulate the NULL record data. Take a look at the API in dns_sd.h for the functions you need. Like a TXT record, a NULL record has a limit of 65535 bytes but unlike the TXT record it isn't segmented.

Here's some sample code (from an iPhone application) to get you started:

        if (ABPersonHasImageData(self.personRecord)) {
                NSData *rawAvatarData = 
(id)ABPersonCopyImageData(self.personRecord);
                
                UIImage *avatarImage = [UIImage imageWithData:rawAvatarData];
                NSData *avatarData = UIImageJPEGRepresentation(avatarImage, 0);
                
                unsigned char hash[CC_SHA1_DIGEST_LENGTH];
                CC_SHA1([avatarData bytes], [avatarData length], hash);
                
NSMutableString *hashString = [NSMutableString stringWithCapacity: (CC_SHA1_DIGEST_LENGTH * 2)];
                
                for (int i = 0; i < CC_SHA1_DIGEST_LENGTH; i++)
                        [hashString appendFormat:@"%02x", (unsigned 
long)hash[i], nil];
                
                [self.TXTProperties setObject:hashString forKey:@"phsh"];
                
                if (avatarRecord == NULL) {
error = DNSServiceAddRecord(_service, &avatarRecord, 0, kDNSServiceType_NULL, [avatarData length], [avatarData bytes], 0);
                } else {
error = DNSServiceUpdateRecord(_service, avatarRecord, 0, [avatarData length], [avatarData bytes], 0);
                }
        } else {
                error = DNSServiceRemoveRecord(_service, avatarRecord, 0);
                avatarRecord = NULL;
                
                [self.TXTProperties removeObjectForKey:@"phsh"];
        }

Keith
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to