Advertisement
kristian

Stack overflow #7841116 -- BNRAppDelegate.h

Oct 20th, 2011
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //
  2. //  BNRAppDelegate.h
  3. //  iTahToodle
  4. //
  5. //  Created by Kristian Freeman on 10/20/11.
  6. //  Copyright (c) 2011 redsashimi, inc. All rights reserved.
  7. //
  8.  
  9. #import <UIKit/UIKit.h>
  10.  
  11. // Declare a helper function that we will use to get a path
  12. // to the location on disk where we can save the to-do list
  13. NSString *docPath(void);
  14.  
  15. @interface BNRAppDelegate : UIResponder
  16. <UIApplicationDelegate, UITableViewDataSource>
  17. {
  18.     UITableView *taskTable;
  19.     UITextField *taskField;
  20.     UIButton     *insertButton;
  21.    
  22.     NSMutableArray *tasks;
  23. }
  24.  
  25. - (void)addTask:(id)sender;
  26.  
  27. #pragma mark - Table View management
  28.  
  29. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  30. {
  31.     // Because this table view only has one section,
  32.     // the number of rows in it is equal to the number
  33.     // of items in our tasks array
  34.     return [tasks count];
  35. }
  36.  
  37. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  38. {
  39.     // To improve performance, we reconfigure cells in memory
  40.     // that have scrolled off the screen and hand them back
  41.     // with new contents instead of always creating new cells.
  42.     // First, we check to see if there's a cell available for reuse.
  43.     UITableViewCell *c = [taskTable dequeueReusableCellWithIdentifier:"Cell"];
  44.     if (!c) {
  45.         // ...and only allocate a new cell if none are available
  46.         c = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:"Cell"];
  47.     }
  48.    
  49.     // Then we (re)configure the cell based on the model object,
  50.     // In this case our todoItems array
  51.     NSString *item = [tasks objectAtIndex:[indexPath row]]; [[c textLabel] setText:item];
  52.    
  53.     // and hand back to the table view the properly configured cell
  54.     return c;
  55. }
  56.  
  57. @property (strong, nonatomic) UIWindow *window;
  58.  
  59. @end
  60.  
  61.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement