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?
大概试试看:
[protocol replaceOccurrencesOfString:@"\\r\\n" withString:@"" options:0 range:NSMakeRange(0, [protocol length])];
**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.**
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.