Does anyone know of an easy way to add a single backslash (\\) to a NSString in Objective-C? I am trying to have a NSString *temp = @\"\\/Dat
This code does give the requested output:
NSString *temp = @"\\/Date(100034234)\\/";
NSLog(@"%@",temp);
However I had an issue with my JSON toolkit (SBJSON) that replaced all occurrances of "\\" with "\\\\", which did cause issues as described in the other answers and the comments.
The result was a string looking like:
@"\\\\/Date(100034234)\\\\/"
See my answer here
The solution was using:
temp = [temp stringByReplacingOccurancesOfString:@"\\\\" withString:@"\\"];