pjv
pjv

Reputation: 183

Extract URL from UIWebView

I am writing a web browser app using UIWebView. I want to be able to save the current URL to a database, just like a bookmark. I have created the standard web browser app such as http://www.youtube.com/watch?v=Vpq8r-HHwZA. Any help please with how I can extract the URL address of the current web view. The goal is to have the URL and a user-given name added to a database using CoreData. The "bookmarks" can then be displayed in a UITableView. I have read many similar SO questions but none of the solutions are quite what I am trying to do. Thank you.

Upvotes: 0

Views: 181

Answers (2)

Anurag Soni
Anurag Soni

Reputation: 1077

i think you need to implement this in a way like, save url when user wants to save/bookmark is so you can implement this like as shown in image below when user press save button then you do whatever you want to do .

- (IBAction)nextButtonPressed:(id)sender
{
    NSString *url = self.webView.request.URL.absoluteString;
    // do whatever you want to do with the URL
}

enter image description here

Upvotes: 1

ArtFeel
ArtFeel

Reputation: 11801

Make sure you set your viewController as the UIWebView delegate, then implement a method:

- (void)webViewDidFinishLoad:(UIWebView *)webView {
  self.currentUrl = webView.request.mainDocumentURL;
}

Upvotes: 2

Related Questions