samir samir - 16 days ago 7
Objective-C Question

NSString replacing character method


Possible Duplicate:

Character encoding in NSString




How i can replace :
/"/"
with :
\"\"
by using the
NSSTring
method :
stringByReplacingOccurrencesOfString


i am doing like this, but it's not working :

myString = [myString stringByReplacingOccurrencesOfString:@"/"/"" withString:@"\"\""];

Answer

If I understood correctly what you want: myString = [myString stringByReplacingOccurrencesOfString:@"/"/"" withString:@"\\\"\\\""];

\ is a special character which says: Careful, don't interpret next characters as you always do. Example: Changing line in a NSString is done withe \n. In others words, do not interpret this "n" like a simple "n". I want a change of line.

Comments