ios - Converting NSData to NSString in NSURLConnection = null -


I am sending data to the server and it is responding to my request and I am getting a text as shown below. Is the web ... where my problem will be NSString * newStr = [[NSString alloc] initWithData: responseData encoding: NSUTF8StringEncoding]; This is not responding to my NSData, while there is data in it feedback data .

My response message:

{ret> 0, msg: "& lt; B> your request has been submitted
Your request number is 123














My code:

  NSString * link = @ "http: //example.jsp"; NSURL * url = [NSURL URLWithString: [NSString stringWithFormat: @ "first_name =% @ and last_name =% @ and phone =% @", link, nameField.text, surnameField.text, phoneField.text]]; NSMutableURL request * request = [NSMutableURL request request withURL: url]; [Set http system: @ "post"]; NSURLResponse * response; NSError * err; NSDT * responseData = [synchronous request to send NSUr connection: Response returning request: Response error: & amp; Err]; NSLog (@ "Reaction Data:% @", Feedback Data); NSString * newStr = [[NSString alloc] initWithData: response data encoding: NSUTF8StringEncoding]; NSLog (@ "Finnish% @", NewST); // New STR is empty !! UIAlertView * Message = [[UIAlertView alloc] initWithTitle: Title Message: newStr Representative: CanceledTaintlinTitle: @ "OK" other buttontitles: zero]; [Show message];  

Your url variable might already be zero Your string ( first_name = ... ) is not a valid URL: it does not even have a plan and host.

I'm sure if you look closely, Xcode is showing a warning that there are three placeholders in your format (% @ ) but you're crossing four arguments Do you really want to do this; [NSString stringWithFormat: @ "% @? First_name =% @ and last_name =% @ and phone =% @", link, NameField.text, surnameField.text, phoneField.text]

/ Code>

(In the beginning, note additional % @? .)

In the comments you mention that you get the data (hence If your call is just a dummy?) If your call [[NSString alloc] initWithData: responseData encoding: NSUTF8StringEncoding] return zero means your responseData is something that is not UTF-8 (which is quite an achievement Land, I have never seen that method fails, I trash withdrawn, but never null not). The part you are quoting looks pretty, though: it's \ r \ n \ r \ n \ r \ n \ r \ n \ r \ n \ r \ n \ r \ n \ r \ n Decoded \ r \ n \ r \ n {rate: 0, msg: "l> B> Y .


Comments

Popular posts from this blog

java - Can't add JTree to JPanel of a JInternalFrame -

javascript - data.match(var) not working it seems -

javascript - How can I pause a jQuery .each() loop, while waiting for user input? -