1

Im getting data from a server by executing this code:

- (void) sendGeneral:(NSString *) general{

    self.responseData = [NSMutableData data];

    NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:CBURL]];

    [request setHTTPMethod:@"POST"];
    int i;
    i = [general length];
    NSLog(@"Length is %i", i);

    [request setHTTPBody:[general dataUsingEncoding:NSUTF8StringEncoding]];

      [[NSURLConnection alloc] initWithRequest:request delegate:self];

}

the data I'm getting after NSLog it to console containing "\r\n" as you can see from the following data (only part of the data to demonstration)

"numberPhoneFrom":"","FormName":"הרשמה\r\n"},{"CallID":314358,"StartDate":"27/07/2011 19:32","TotalTime":51.0,"numberPhoneFrom":"","FormName":"פרטים כלליים\r\n"},{"CallID":424378,"StartDate":"26/09/2011 18:43","TotalTime":63.6,"numberPhoneFrom":"","FormName":"הרשמה\r\n"},{"CallID":311229,"StartDate":"26/07/2011 13:28","TotalTime":18.6,"numberPhoneFrom":"","FormName":"נסיון\r\n"}

Im trying to clean the "\r\n" with all kind of commands but i can't do it this code get the data in the protocol

- (void) GetData: (NSMutableString *)protocol{
     [protocol replaceOccurrencesOfString:@"\n"  withString:@"" options:0 range:NSMakeRange(0, [protocol length])]; 
      NSLog(@"server data Function%@", protocol);
} 

Getting the data back from server in hear in NSMutableString

/*****************************************************************/
/* connection finish loading and continue talk                   */
/*****************************************************************/

    - (void) connectionDidFinishLoading:(NSURLConnection *)connection {
        [connection release];

       NSMutableString* responseString = [[NSMutableString alloc] initWithData:responseData encoding:NSUTF8StringEncoding];


      //  NSLog(@"the Server Response was %@", responseString);
         [[self delegate] GetData:responseString];


    }

can anyone help?

Shimon Wiener
  • 1,142
  • 4
  • 18
  • 39

2 Answers2

0

Probably try this:

[protocol replaceOccurrencesOfString:@"\\r\\n"  withString:@"" options:0 range:NSMakeRange(0, [protocol length])]; 
iDifferent
  • 2,190
  • 1
  • 14
  • 19
0

**Solved this issue on the server, i think this is the best thing to do' servers are much stronger and C# is very good in string handeling

Thank you.**

Shimon Wiener
  • 1,142
  • 4
  • 18
  • 39