Re: Base64 encoding of NSImage
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