Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JavaScriptCore #2

Open
massimobio opened this issue Nov 30, 2020 · 0 comments
Open

JavaScriptCore #2

massimobio opened this issue Nov 30, 2020 · 0 comments

Comments

@massimobio
Copy link
Owner

See if we there is a better way to deal with JavaScript instead of sending raw strings to the web view.
For example using JavaScritpCore:

    lazy var context: JSContext? = {
        let context = JSContext()
      
        guard let
            commonJSPath = Bundle.main.path(forResource: "opensheetmusicdisplay.min", ofType: "js") else {
            print("Unable to read resource files.")
            return nil
        }
      
        do {
            let common = try String(contentsOfFile: commonJSPath, encoding: String.Encoding.utf8)
            _ = context?.evaluateScript(common)
        } catch {
            print("Error while processing script file: \(error)")
        }
      
        return context
    }()
    
    override func viewDidLoad() {
        super.viewDidLoad()
        guard let context = context else {
          print("JSContext not found.")
          return
        }
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant