• 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: Making an NSString from NSData
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Making an NSString from NSData


  • Subject: Re: Making an NSString from NSData
  • From: Jeffrey J Barbose <email@hidden>
  • Date: Mon, 22 Oct 2001 19:46:44 -0700

if you know that the NSString contains simple ascii data (like a c-string or a pascal string), the simple case is something like this:

NSString* myString = "foo";
NSData* myData = [NSData dataWithBytes:[myString cString] length:[myString cStringLength]];

you can also look at NSStringEncodings and getCharacters... for unicode and other encodings of strings..




At 19.13 -0700 01/10/22, Sam Goldman wrote:
How do I make an NSString into NSData? Do have to go through every byte and
put that into a string? I don't really know what NSData is because it can
contain images (as I learned from cocoadevcentral's image buddy) and I just
don9t know what its content would be. Sorry for the newbie question, but I
couldn't do it when I tried.

- Sam
_______________________________________________
cocoa-dev mailing list
email@hidden
http://www.lists.apple.com/mailman/listinfo/cocoa-dev


References: 
 >Making an NSString from NSData (From: Sam Goldman <email@hidden>)

  • Prev by Date: Re: converting C-strings to NSString
  • Next by Date: Re: Performance issues w/ keystroke events (newbie false alarm :)
  • Previous by thread: Making an NSString from NSData
  • Next by thread: Re: Making an NSString from NSData
  • Index(es):
    • Date
    • Thread