myCode is here
// titleScript = "document.querySelector('#\(rawValue) span')?.textContent"
guard let titleResult = try? await webView.evaluateJavaScript(type.titleScript),
let title = titleResult as? String else { return }
this code has error
Thread 1: Swift runtime failure: Unexpectedly found nil while implicitly unwrapping an Optional value
but edit Code like this It is works Successful
do {
...
let titleResult = try await webView.evaluateJavaScript(type.titleScript)
let title = titleResult as? String
...
} catch {
LogManager.log(level: .error, self, #function, error, "title is Invalid : \(type.titleScript)")
continue
}
I don't know why guard let _ = try? is Fail
It’s better to reply as a reply, rather than in the comments; see Quinn’s Top Ten DevForums Tips for this and other titbits.
My advice here is that you pull this code out into a small test project and confirm the issue there. That might help you isolate what’s going on but, if you still can’t figure it out, post a URL [1] to download your test project and I’d be happy to take a look.
IMPORTANT I’m looking for a small test project, similar to the example I posted above. If you post something that’s large, or relies on third-party tools or libraries, I won’t have time to look at it.
Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"
[1] If you have troubles posting your URL, do that in the clear, per tip 14.