• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: TXT Records with NSImages
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: TXT Records with NSImages


  • Subject: Re: TXT Records with NSImages
  • From: Michael Ash <email@hidden>
  • Date: Fri, 13 Mar 2009 09:59:29 -0400

On Fri, Mar 13, 2009 at 8:45 AM, Joe Turner <email@hidden> wrote:
> Here:
>
> NSImage *original = [NSImage imageNamed:NSImageNameComputer];
>                [original setSize:NSMakeSize(10.0f, 10.0f)];
>                NSData *image = [original TIFFRepresentation];
>                NSBitmapImageRep *imageRep = [NSBitmapImageRep
> imageRepWithData:image];
>                NSData *finalData = [imageRep
> representationUsingType:NSPNGFileType properties:nil];
>                NSDictionary *txtRecord = [NSDictionary
> dictionaryWithObject:finalData forKey:@"image"];
>                NSData *data = [NSNetService
> dataFromTXTRecordDictionary:txtRecord];
>                if (data)
>                        NSLog(@"Data is not nil!");
>                [netService setTXTRecordData:data];

That all looks fine (except for the manipulation of the "original"
image, which could be a shared object; make a copy, manipulate that)
but I just remembered something from the Zeroconf spec:

"The format of each constituent string within the DNS TXT record is a
single length byte, followed by 0-255 bytes of text data."

In other words, the total length of each TXT record entry, counting
the key, the value, and the equals sign that separates them, cannot
exceed 255 bytes.

You'll either have to *really* shrink your picture, or find another
way to transmit it.

Mike
_______________________________________________

Cocoa-dev mailing list (email@hidden)

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:

This email sent to email@hidden

References: 
 >TXT Records with NSImages (From: Joe Turner <email@hidden>)
 >Re: TXT Records with NSImages (From: Alexander Spohr <email@hidden>)
 >Re: TXT Records with NSImages (From: Joe Turner <email@hidden>)
 >Re: TXT Records with NSImages (From: Michael Ash <email@hidden>)
 >Re: TXT Records with NSImages (From: Joe Turner <email@hidden>)

  • Prev by Date: Re: cocoa file APIs
  • Next by Date: Re: NSTextFieldCell text color issue in NSTableView with source list highlighting
  • Previous by thread: Re: TXT Records with NSImages
  • Next by thread: Re: TXT Records with NSImages
  • Index(es):
    • Date
    • Thread