• 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: NSStrings and data bytes
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSStrings and data bytes


  • Subject: Re: NSStrings and data bytes
  • From: Damien Sorresso <email@hidden>
  • Date: Mon, 26 Jun 2006 22:58:27 -0500

On 26 Jun, 2006, at 9:31 PM, D.K. Johnston wrote:
I want to read the bytes from a file as an NSString so I can use scanners, etc. But then I need to get at the original bytes in order to process them. (Sometimes I even have to get the right and left nibbles of a byte.) I've been playing around with NSString methods like cStringUsingEncoding:, but I can't seem to get the bytes back. Any suggestions?

Go the other way around. Read the bytes into an NSData object and then use initWithData:encoding: to get the string for your text, specifying the proper encoding, of course. From there, just do your work with NSScanner on that object. (I assume the order in which your data and string are created doesn't matter.)


You can also use NSString's initWithBytes:length:encoding: if you just want to read in the data using the standard C libraries.
--


Damien Sorresso

Mac OS X Developer
Computer Infrastructure Support Services
Illinois State University
E-mail: email@hidden


Attachment: smime.p7s
Description: S/MIME cryptographic signature

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: NSStrings and data bytes
      • From: Ricky Sharp <email@hidden>
References: 
 >NSStrings and data bytes (From: "D.K. Johnston" <email@hidden>)

  • Prev by Date: how do I use a SEL from another class?
  • Next by Date: General Remote CoreData Stores Question
  • Previous by thread: NSStrings and data bytes
  • Next by thread: Re: NSStrings and data bytes
  • Index(es):
    • Date
    • Thread