PDA

View Full Version : Convert NSMutableData to NSString




arme
Sep 24, 2008, 03:25 AM
NSString *tmp = [[NSString alloc] initWithData:receivedData encoding:UTF8Char];

Error before encoding .



robbieduncan
Sep 24, 2008, 03:28 AM
As we are not mind readers could you post the error? And anything else relevant?

arme
Sep 24, 2008, 03:41 AM
I receive a request from url. that is a string( OK or NOK) .it is save in NSSMUutableData . i need convert to NSString. have are you a idea?

robbieduncan
Sep 24, 2008, 03:47 AM
I know what you are trying to do. You've posted about it over and over and over and over and over and over and over and....

You say "Error before encoding". What is the error. Unless you are willing to post questions with enough detail you are not going to get answers.

arme
Sep 24, 2008, 04:07 AM
error message is syntax error before encoding.
and the remind of code is correct.
please give me an idea that solve converting?
thanks

robbieduncan
Sep 24, 2008, 04:22 AM
error message is syntax error before encoding.

Then you have typed something incorrectly somewhere. Not necessarily on that line: you may have forgotten a ; or a ] somewhere else.

In my own code I'm using this (not sure why I chose this method over that one):


NSString *sourceSt = [[NSString alloc] initWithBytes:[downloadedData bytes] length:[downloadedData length] encoding:NSUTF8StringEncoding];

arme
Sep 24, 2008, 04:29 AM
thank you.