• 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: Base64 encoding of NSImage
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Base64 encoding of NSImage


  • Subject: Re: Base64 encoding of NSImage
  • From: David Riggle <email@hidden>
  • Date: Sun, 01 Jul 2012 12:16:56 -0700

This is what I use. Short and sweet.

@implementation NSData (Base64)

- (NSData *)dataWithBase64Encoding
{
	CFDataRef retval = NULL;
	SecTransformRef encodeTrans = SecEncodeTransformCreate(kSecBase64Encoding, NULL);
	if (encodeTrans != NULL) {
		if (SecTransformSetAttribute(encodeTrans, kSecTransformInputAttributeName, (__bridge CFDataRef)self, NULL))
			retval = SecTransformExecute(encodeTrans, NULL);
		CFRelease(encodeTrans);
	}
	return CFBridgingRelease(retval);
}

- (NSData *)dataFromBase64Decoding
{
	CFDataRef retval = NULL;
	SecTransformRef decodeTrans = SecDecodeTransformCreate(kSecBase64Encoding, NULL);
	if (decodeTrans != NULL) {
		if (SecTransformSetAttribute(decodeTrans, kSecTransformInputAttributeName, (__bridge CFDataRef)self, NULL))
			retval = SecTransformExecute(decodeTrans, NULL);
		CFRelease(decodeTrans);
	}
	return CFBridgingRelease(retval);
}

@end

_______________________________________________

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

  • Follow-Ups:
    • Re: Base64 encoding of NSImage
      • From: Jens Alfke <email@hidden>
  • Prev by Date: How to copy class interface and implementation without connections to .xib file
  • Next by Date: Re: How to copy class interface and implementation without connections to .xib file
  • Previous by thread: Re: Base64 encoding of NSImage
  • Next by thread: Re: Base64 encoding of NSImage
  • Index(es):
    • Date
    • Thread