• 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
Newbie: Encoding NSData to a string
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Newbie: Encoding NSData to a string


  • Subject: Newbie: Encoding NSData to a string
  • From: Joao Lourenco <email@hidden>
  • Date: Mon, 26 Mar 2007 07:05:53 +0200

Hello

I'm starting to learn Cocoa and would like to do the following

Read an image from a file
Encode the image as an "ascii" string
Send the image as an ASCII string in the body of a post message

This is the code I have so far:
Code:

NSImage *pictureToSend = [[NSImage alloc] initWithContentsOfFile: filePath];
NSData *dataEncodedPicture = [pictureToSend TIFFRepresentation];
// do whatever you need to do to create and/or modify your NSImage
NSBitmapImageRep *imageRep = [NSBitmapImageRep imageRepWithData:dataEncodedPicture];
NSDictionary *imageProps = [NSDictionary dictionaryWithObject: [NSNumber numberWithFloat:0.9] forKey:NSImageCompressionFactor];
dataEncodedPicture = [imageRep representationUsingType:NSJPEGFileType properties:imageProps];
NSString* stringEncodedPicture = [[NSString alloc] initWithData: dataEncodedPicture encoding: NSUTF8StringEncoding];
NSLog(stringEncodedPicture);


All is well until: stringEncodedPicture = [[NSString alloc] initWithData: dataEncodedPicture encoding: NSUTF8StringEncoding];
I am sure I am doing something wrong, I just don't know what.


Thanks for the help
Joao
_______________________________________________

Cocoa-dev mailing list (email@hidden)

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: Newbie: Encoding NSData to a string
      • From: Nir Soffer <email@hidden>
    • Re: Newbie: Encoding NSData to a string
      • From: James Bucanek <email@hidden>
    • Re: Newbie: Encoding NSData to a string
      • From: Andreas Mayer <email@hidden>
  • Prev by Date: Re: Localization of standard paths necessary?
  • Next by Date: Re: Newbie: Encoding NSData to a string
  • Previous by thread: Re: Localization of standard paths necessary?
  • Next by thread: Re: Newbie: Encoding NSData to a string
  • Index(es):
    • Date
    • Thread