iosobjective-cstripslashes

Remove slashes from large paragraph


In iOS app, I send data through JSON to iPhone device. My paragraph is large text containing multiple newline. Similarly to stripslashes, how can I remove slash along with them in iOS Objective-C?


Solution

  • No you have to do it manually. E.g.:

    NSString *str = @"Test string with some \' and some \" \'\"";
    str = [str stringByReplacingOccurrencesOfString:@"\'" withString:@"'"];
    str = [str stringByReplacingOccurrencesOfString:@"\\\"" withString:@"\""];
    NSLog(@"%@", str);