views:

46

answers:

2

Hi

I have an iPhone app that shows the user a UIWebView in the first view, what I am trying to do is allow the user to save what is essentially favorites to be saved and then displayed in a table view in the second view. To do this all i need is the page URL and also the Page Title to be saved to then populate the table view. Now here is the problem I am just starting to learn how to make iPhone apps and I have no clue what would be the best way to save it and how to get this information from the web view?

+1  A: 

Implement the UIWebViewDelegate protocol. You can obtain the URL from the request object in the delegate method -webView:shouldStartLoadWithRequest:navigationType:

To extract the title from the HTML, run some Javascript on the content using – stringByEvaluatingJavaScriptFromString:. Make sure you do this after the content is fully loaded, i.e. in the delegate method - (void)webViewDidFinishLoad:(UIWebView *)webView

hyn
A: 

Hi, To populate and display in a TableView, you have to have some sort of a DataSource, preferably an NSArray, since you shall be appending or altering this array, use a NSMutableArray. Now to save two bits of information, the URL and the Title, have two arrays, one for Title and one for the URL. (Since the title can be customised).

In the TableView delegate, where you return the number of rows, return [URLArray count]; and in the function to populate the cell, set the Text to [titleArray objectAtIndex:[indexPath row]] and the SubTitle to [URLArray objectAtIndex:[indexPath row]];

Hope this resolves your question and is what you were looking for.

Jayant