I'm trying to pass the following string:
NSString* jsString = [NSString stringWithFormat:@"myFunc(\"%@\");", myParameter];
from Objective C to JavaScript using the stringByEvaluatingJavaScriptFromString, where myParameter is a string value. How can I ensure that the myParameter string doesn't contain any JS-unsafe characters without being properly escaped?
E.g. the following string would mess things up:
parameter");alert('scam');
The myParameter string will be the name of a contact from the address book, making it perfectly possible to have the above string entered.