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 My response message: My code: NSString * newStr = [[NSString alloc] initWithData: responseData encoding: NSUTF8StringEncoding];
This is not responding to my NSData, while there is data in it feedback data .
{ret> 0, msg: "& lt; B> your request has been submitted
Your request number is 123
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]
(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
Post a Comment