Graphics Programs Reference
In-Depth Information
@class WebViewController;
@interface ListViewController : UITableViewController <NSXMLParserDelegate>
{
NSURLConnection *connection;
NSMutableData *xmlData;
RSSChannel *channel;
}
@property (nonatomic, strong) WebViewController *webViewController;
- (void)fetchEntries;
@end
In
ListViewController.m
, import the header file and synthesize the property.
#import "WebViewController.h"
@implementation ListViewController
@synthesize webViewController;
In
NerdfeedAppDelegate.m
, import the header for
WebViewController
, create
an instance of
WebViewController
, and set it as the
webViewController
of the
ListViewController
.
#import "WebViewController.h"
@implementation NerdfeedAppDelegate
- (BOOL)application:(UIApplication *)application
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
ListViewController *lvc =
[[ListViewController alloc] initWithStyle:UITableViewStylePlain];
UINavigationController *masterNav =
[[UINavigationController alloc] initWithRootViewController:lvc];
WebViewController *wvc = [[WebViewController alloc] init];
[lvc setWebViewController:wvc];
[[self window] setRootViewController:masterNav];
self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];
return YES;
}
(Note that we are instantiating the
WebViewController
in the application delegate in
preparation for the next chapter where we will use a
UISplitViewController
to
present view controllers on the iPad.)
When the user taps on a row in the table view, we want the
WebViewController
to be
pushed onto the navigation stack and the link for the selected
RSSItem
to be loaded in its
web view. To have a web view load a web page, you send it the message
loadRequest:
. The argument is an instance of
NSURLRequest
that contains the