Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to remove new line characters from NSString in a webservice response?
    text
    copied!<p>I am presently getting a Webservice Response which contains many new line characters. I have tried the following approaches but still i am not able to eliminate the New Line Characters.</p> <p>1) </p> <pre><code>responseString = [responseString stringByReplacingOccurrencesOfString:@"\n" withString:@""]; </code></pre> <p>2)</p> <pre><code>responseString = [responseString stringByTrimmingCharactersInSet:[NSCharacterSet newlineCharacterSet]]; </code></pre> <p>3)</p> <pre><code>NSRange foundRange = [responseString rangeOfString:@"\n"]; if (foundRange.location != NSNotFound) [responseString stringByReplacingOccurrencesOfString:@"\n" withString:@"" options:0 range:foundRange]; </code></pre> <p>My Webservice respsonse is in this format.</p> <pre><code>META NAME="ColdFusionMXEdition" CONTENT="ColdFusion DevNet Edition - Not for Production Use."? wddxPacket version='1.0'&gt;&lt;header/&gt;&lt;data&gt;&lt;string&gt;{"MESSAGE":"","CODE":1,"RESPONSE":{"FILENAME":"CustomerSkillsIntro","PLAYLIST":[{"TIMEOUT":73,"TITLE":"Greet","QUESTIONNUMBER":1,"TIMEIN":71,"VALIDRESPONSE":1},{"TIMEOUT":77,"TITLE":"Have Name Tag","QUESTIONNUMBER":2,"TIMEIN":74,"VALIDRESPONSE":1},{"TIMEOUT":83,"TITLE":"Greet","QUESTIONNUMBER":3,"TIMEIN":78,"VALIDRESPONSE":1},{"TIMEOUT":112,"TITLE":"Helping Do My Job","QUESTIONNUMBER":4,"TIMEIN":109,"VALIDRESPONSE":1},{"TIMEOUT":134,"TITLE":"Greet Happily","QUESTIONNUMBER":5,"TIMEIN":131,"VALIDRESPONSE":1},{"TIMEOUT":144,"TITLE":"Stay cheerful when resident is crabby","QUESTIONNUMBER":6,"TIMEIN":141,"VALIDRESPONSE":1},{"TIMEOUT":154,"TITLE":"Bond with the new resident","QUESTIONNUMBER":7,"TIMEIN":151,"VALIDRESPONSE":1},................... </code></pre> <p>My requirement is to capture only the part of the string from <code>{"MESSAGE":"","CODE":1,</code> till the end. But i am getting too many white spaces and new line characters before the required part.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload