Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //
- // BooksTVController.m
- // NEW
- //
- // Created by JasonBuckalew on 1/17/10.
- // Copyright 2010 __MyCompanyName__. All rights reserved.
- //
- #import "BooksTVController.h"
- #import "LIBAppDelegate.h"
- #import "Books.h"
- #import "BookDetailViewController.h"
- #import "MyXMLBookParser.h"
- @implementation BooksTVController
- NSArray *books = [MyXMLBookParser getBookData];
- - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
- return 1;
- }
- - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
- return [appDelegate.books count];
- }
- - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
- static NSString *CellIdentifier = @"Cell";
- UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
- if (cell == nil) {
- cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease];
- }
- Book *aBook = [appDelegate.books objectAtIndex:indexPath.row];
- cell.text = aBook.title;
- cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
- // Set up the cell
- return cell;
- }
- - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
- // Navigation logic -- create and push a new view controller
- if(bdvController == nil)
- bdvController = [[BookDetailViewController alloc] initWithNibName:@"BookDetailView" bundle:[NSBundle mainBundle]];
- Book *aBook = [appDelegate.books objectAtIndex:indexPath.row];
- bdvController.aBook = aBook;
- [self.navigationController pushViewController:bdvController animated:YES];
- }
- - (void)viewDidLoad {
- [super viewDidLoad];
- // Uncomment the following line to add the Edit button to the navigation bar.
- // self.navigationItem.rightBarButtonItem = self.editButtonItem;
- appDelegate = (LIBAppDelegate *)[[UIApplication sharedApplication] delegate];
- self.title = @"Tips";
- }
- /*
- - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
- // Return YES for supported orientations
- return (interfaceOrientation == UIInterfaceOrientationPortrait);
- }
- */
- - (void)didReceiveMemoryWarning {
- [super didReceiveMemoryWarning]; // Releases the view if it doesn't have a superview
- // Release anything that's not essential, such as cached data
- }
- - (void)dealloc {
- [bdvController release];
- [appDelegate release];
- [super dealloc];
- }
- @end
Add Comment
Please, Sign In to add comment