Guest User

Untitled

a guest
Jul 22nd, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.52 KB | None | 0 0
  1. //
  2. // BooksTVController.m
  3. // NEW
  4. //
  5. // Created by JasonBuckalew on 1/17/10.
  6. // Copyright 2010 __MyCompanyName__. All rights reserved.
  7. //
  8.  
  9. #import "BooksTVController.h"
  10. #import "LIBAppDelegate.h"
  11. #import "Books.h"
  12. #import "BookDetailViewController.h"
  13. #import "MyXMLBookParser.h"
  14.  
  15. @implementation BooksTVController
  16.  
  17. NSArray *books = [MyXMLBookParser getBookData];
  18.  
  19.  
  20. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
  21. return 1;
  22. }
  23.  
  24.  
  25. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  26. return [appDelegate.books count];
  27. }
  28.  
  29.  
  30. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  31.  
  32. static NSString *CellIdentifier = @"Cell";
  33.  
  34. UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
  35. if (cell == nil) {
  36. cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease];
  37. }
  38.  
  39. Book *aBook = [appDelegate.books objectAtIndex:indexPath.row];
  40.  
  41. cell.text = aBook.title;
  42. cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
  43.  
  44. // Set up the cell
  45. return cell;
  46. }
  47.  
  48.  
  49. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
  50. // Navigation logic -- create and push a new view controller
  51.  
  52. if(bdvController == nil)
  53. bdvController = [[BookDetailViewController alloc] initWithNibName:@"BookDetailView" bundle:[NSBundle mainBundle]];
  54.  
  55. Book *aBook = [appDelegate.books objectAtIndex:indexPath.row];
  56.  
  57. bdvController.aBook = aBook;
  58.  
  59. [self.navigationController pushViewController:bdvController animated:YES];
  60. }
  61.  
  62.  
  63. - (void)viewDidLoad {
  64. [super viewDidLoad];
  65. // Uncomment the following line to add the Edit button to the navigation bar.
  66. // self.navigationItem.rightBarButtonItem = self.editButtonItem;
  67.  
  68. appDelegate = (LIBAppDelegate *)[[UIApplication sharedApplication] delegate];
  69.  
  70. self.title = @"Tips";
  71. }
  72. /*
  73. - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
  74. // Return YES for supported orientations
  75. return (interfaceOrientation == UIInterfaceOrientationPortrait);
  76. }
  77.  
  78. */
  79. - (void)didReceiveMemoryWarning {
  80. [super didReceiveMemoryWarning]; // Releases the view if it doesn't have a superview
  81. // Release anything that's not essential, such as cached data
  82. }
  83.  
  84.  
  85. - (void)dealloc {
  86. [bdvController release];
  87. [appDelegate release];
  88. [super dealloc];
  89. }
  90.  
  91.  
  92. @end
Add Comment
Please, Sign In to add comment