Advertisement
Guest User

Untitled

a guest
Apr 28th, 2015
229
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //
  2. //  HomeViewController.m
  3. //  UITableViewExample
  4. //
  5. //  Created by Mani Shankar on 16/06/14.
  6. //  Copyright (c) 2014 makemegeek. All rights reserved.
  7. //
  8.  
  9. #import "HomeViewController.h"
  10.  
  11. @interface HomeViewController ()
  12.  
  13. @end
  14.  
  15. @implementation HomeViewController
  16. @synthesize tableData,tableViewObject;
  17.  
  18. - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
  19. {
  20.     self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
  21.     if (self) {
  22.         // Custom initialization
  23.     }
  24.     return self;
  25. }
  26.  
  27. - (void)viewDidLoad
  28. {
  29.     [super viewDidLoad];
  30.     tableData = [[NSMutableArray alloc] initWithObjects:@"One",@"Two",@"Three",@"Four",@"Five",@"Six",@"Seven",@"Eight",@"Nine",@"Ten",nil];
  31. }
  32.  
  33. - (void)didReceiveMemoryWarning
  34. {
  35.     [super didReceiveMemoryWarning];
  36.     // Dispose of any resources that can be recreated.
  37. }
  38.  
  39. #pragma - markup TableView Delegate Methods
  40. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  41. {
  42.     return [tableData count];
  43. }
  44.  
  45. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  46. {
  47.     static NSString *simpleTableIdentifier = @"SimpleTableItem";
  48.    
  49.     UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier];
  50.    
  51.     if (cell == nil) {
  52.         cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:simpleTableIdentifier];
  53.     }
  54.    
  55.     cell.textLabel.text = [tableData objectAtIndex:indexPath.row];
  56.     cell.imageView.image = [UIImage imageNamed:@"geekPic.jpg"];
  57.     return cell;gtg
  58. }
  59.  
  60. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
  61. {
  62.     UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Alert" message:[NSString stringWithFormat:@"Selected Value is
  63. %@",[tableData objectAtIndex:indexPath.row]] delegate:self cancelButtonTitle:@"Ok"
  64.  otherButtonTitles:nil];
  65.     [alertView show];
  66. }
  67. @end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement