Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

150
Visualizações
javascript ValueCallback not working in swift

I have this javascript code below that i want run in swift to extract html but i got the following error: Cannot find ValueCallback in scope.

view.evaluateJavascript(
    "(function() { return ('<html>'+document.getElementById('html').innerHTML+'</html>'); })();",
    new ValueCallback<String>() {
        @Override
        public void onReceiveValue(String html) {
            print(html);
        }
    }
);
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

evaluateJavascript function has a different signature

/* @abstract Evaluates the given JavaScript string.
  @param javaScriptString The JavaScript string to evaluate.
  @param completionHandler A block to invoke when script evaluation completes or fails.
  @discussion The completionHandler is passed the result of the script evaluation or an error.
  Calling this method is equivalent to calling `evaluateJavaScript:inFrame:inContentWorld:completionHandler:` with:
    - A `frame` value of `nil` to represent the main frame
    - A `contentWorld` value of `WKContentWorld.pageWorld`
    */
  open func evaluateJavaScript(_ javaScriptString: String, completionHandler: ((Any?, Error?) -> Void)? = nil)

You'd need to change your code to

view.evaluateJavascript("(function() { return ('<html>'+document.getElementById('html').innerHTML+'</html>'); })();") { value, error in
  print(value)
)
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda