I was wondering if I can use JavaScript with Objective-C to parse data.
I saw examples of getting NSMutableData
from a web server.
I was wondering if I could then use JavaScript methods for parsing the data in the DOM tree (ie getElementById
).
I was wondering if I can use JavaScript with Objective-C to parse data.
I saw examples of getting NSMutableData
from a web server.
I was wondering if I could then use JavaScript methods for parsing the data in the DOM tree (ie getElementById
).
I'm not entirely sure what you mean, but you can definitely use JavaScript with Objective-C. On iOS, you could put the NSData
that you got from a server into a UIWebView
with the loadData:MIMEType:textEncodingName:baseURL:
method. Then you can use stringByEvaluatingJavaScriptFromString:
to run any JavaScript on the stuff you put into the web view.
There's a second option. You could use JavaScriptCore directly, but I don't think that's what you're looking for: Embed a JavaScript engine in an iOS application