Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

converting data back into a string

So I have this:

  NSData *charlieSendData = [[charlieImputText stringValue] dataUsingEncoding:NSUTF8StringEncoding]; 

I know how to convert NSStrings to data but how I convert data back to an NSString?

Elijah

like image 859
objectiveccoder001 Avatar asked Aug 09 '10 01:08

objectiveccoder001


People also ask

How to convert a variable to a string in Python?

Converting Numbers to Strings We can convert numbers to strings through using the str() method. We'll pass either a number or a variable into the parentheses of the method and then that numeric value will be converted into a string value.

How do you convert something to string in go?

You can convert numbers to strings by using the strconv. Itoa method from the strconv package in the Go standard libary. If you pass either a number or a variable into the parentheses of the method, that numeric value will be converted into a string value.

How do you turn something into a string in Javascript?

Values can be explicitly converted to strings by calling either String() or n. toString() . With the String() function, let's convert a Boolean value to a string by passing the value true into the parameters for String() .

How to turn string into number Python?

Introduction. Python allows you to convert strings, integers, and floats interchangeably in a few different ways. The simplest way to do this is using the basic str() , int() , and float() functions.


1 Answers

You can use NSString's -initWithData:encoding: initializer method.

NSData *charlieSendData = [[charlieImputText stringValue] dataUsingEncoding:NSUTF8StringEncoding] NSString *charlieSendString = [[NSString alloc] initWithData:charlieSendData encoding:NSUTF8StringEncoding]; 
like image 100
Jacob Relkin Avatar answered Oct 12 '22 16:10

Jacob Relkin