Skip to content

JavaScriptCore #2

@massimobio

Description

@massimobio

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
        }
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions