Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get the current URL of Cocoa's WebView

Im new to Cocoa.

I'm trying to extract the URL of the currently loaded webpage in my WebView object. I use this WebView to show a login screen and after logging in I have to get some parts of the URL.

I have already tried

[[[[frame provisionalDataSource] request] URL] absoluteString];

but this one only works one time, when called while loading. If the loading is complete it returns "(null)". The problem is, that it seems like the URL changes while loading the page so i get the wrong URL.

Does anybody know how to get the URL at any time I want?

Thanks

like image 741
Meuuuy Avatar asked Feb 02 '23 15:02

Meuuuy


1 Answers

Switch provisionalDataSource with dataSource. Once the frame starts loading, it's not provisional anymore.

like image 121
Rob Napier Avatar answered Feb 05 '23 05:02

Rob Napier