My question is how do I grab the value of a WebView. I am unsure which property allows me to use a WebView.

@IBOutlet weak var videoTemp: WebView!
let videoPassed = videoTemp

How do I access this videoTemp's value much like .stringvalue and .image

I have URL's to Youtube videos stored in a database that I have already pulled in via JSON and I am trying to pass them from one view to another. I have a method to setup my videos but when I try to access the values I am unsure which property of WebView is necessary to access them much like .stringValue can access a string and .image can access an image

Regardless, web views don’t expose their content directly like image views. Rather you’d typically ask the web view for its URL and pass that around.

Having said that, I suspect you’ve got the wrong end of the stick here. In general you only need to get the content out of a view if the user is editing. So, for example, in the case of an image view you’d very rarely read the image property. Rather, your view controller would know what image it put into the view because it put it there.

So, unless you’re trying to get the URL that the user has navigated to, you’d normally just keep a copy of the URL that you used to set up the web view in the first place, which avoids this issue entirely.

Thank you. I did not know there was a more modern WKWebView. When I switched over to the more modern WKWebView I started to get a fatal error which occurs on line 64. My print(url) statement works and prints out all of my urls to my videos on Youtube. As you can see I am not using a static hard coded URL. My URL's are dynamic based on clicking on a specific collection view item.

"fatal error: unexpectedly found nil while unwrapping an Optional value"

Instead of trying to move the web view from one view controller to another I simply passed the URL and handled the URL on the second Controller. But you are correct that my videoTemp was nil. Thank you!

More Like This

Retrieving data ...

This site contains user submitted content, comments and opinions and is for informational purposes only. Apple disclaims any and all liability for the acts, omissions and conduct of any third parties in connection with or related to your use of the site. All postings and use of the content on this site are subject to the Apple Developer Forums Participation Agreement.