Search code examples
iosjavascriptcore

iOS JavaScriptCore convert from string to JSValue


I'm using JavascriptCore. Value from the JavaScript side are wrapped in JSValue. I'm assuming sending data from Swift/Objective-C side to the Javascript side also uses JSValue.

However, I noticed that there are calls like valueWithDouble:inContext, but how come there is not one for NSString?


Solution

  • It turns out it's not necessary to use JSValue when passing string back to JavaScript. Just use NSString directly.