I'm developing an iOS 7 app that has scripting capabilities using JavascriptCore.
I'd like to have a way to pause or completely stop the code currently running on the JSContext. JavascriptCore isn't really well documented so I couldn't find an answer.
I have a few ideas:
but hopefully there are better ways.
Any help would be appreciated. Thanks!
There actually is an API that allows to stop execution of Javascript code inside of JavascriptCore. Unfortunately though, it is private and thus cannot be used within apps that are to be distributed through the App Store.
The API in question is the JSContextGroupSetExecutionTimeLimit
function defined in JSContextRefPrivate. Not only does it allow to specify a timeout for your JS code, but also a callback that will be called regularly to determine whether the execution should be stopped.
You can find more information in my answer to this SO question.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With