What's new
Apple iPad Forum 🍎

Welcome to the Apple iPad Forum, your one stop source for all things iPad. Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your own topics and posts, as well as connect with other members through your own private inbox!

Calling Webview from anther View Controller class

ray10

iPF Noob
Joined
Feb 24, 2011
Messages
1
Reaction score
0
Hi everyone, I'm new to this as I come from C++ and Perl background. Trying to learn from books but they are missing some core concepts of Objective-C. I need some help on this code to pull a webpage:

RootViewController.m
Code:
- (void)fetchWebsite:(NSString*)website{
    NSLog(@"address: %@", website);
    
    NSString *urlAddress = website;
    NSURL *url = [NSURL URLWithString:urlAddress];
    NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
    [webImageDisplay loadRequest:requestObj];
    [webImageDisplay release];
}

- (void)viewDidLoad {
    [self fetchWebsite:@"website here"];
    [super viewDidLoad];
}
This code works just fine but what I'm having trouble is calling this method from another class, like the code below:

AnotherViewController.m
Code:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {

    NSString *itemRequested = [conusItems objectAtIndex:indexPath.row];
    NSLog(@"logging: %@", itemRequested);

    RootViewController *parent = [[RootViewController alloc] init];
    [parent fetchWebsite:@"another website here"];
    
    [itemRequested release];

}
I click on the button on the table view and I see the code is being called in the RootViewController with the NSLog but it doesn't seem to display the new page. Any ideas? Thanks
 

Most reactions

Latest posts

Top