我从带有反斜杠字符的 json 响应中得到一个字符串作为字符串。我想从 url 中删除 '\' 字符。我建立了代码,但它不起作用。代码在这里:
NSString *responseData = [[NSString alloc]initWithData:[NSData dataWithContentsOfURL:url] encoding:NSUTF8StringEncoding];
NSString* encodedString = [responseData stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSLog(@"Response ==> %@" ,encodedString);
// here encodedString is a url which is showing crctly in output and need to trim the \ character.
// NSString* str = [NSString stringWithFormat: @"encodedString"];
// str = [str stringByReplacingOccurrencesOfString:@"?" withString:@""];
// NSLog(@"Response ==> %@" , str);
encodedString = [encodedString stringByReplacingOccurrencesOfString:@"\\" withString:@""];
NSLog(@"Response ==> %@" ,encodedString);
但我无法删除字符。