-
-
Save musawirali/3fbf24e116f0899f175d to your computer and use it in GitHub Desktop.
Typical view controller with a simple table
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@interface ViewController () | |
@property (strong, nonatomic) NSArray * items; | |
@end | |
@implementation ViewController | |
@synthesize items = _items; | |
- (NSArray *)items | |
{ | |
if (!_items) | |
_items = @[@"Item1", @"Item2", @"Item3", @"Item4"]; | |
return _items; | |
} | |
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section | |
{ | |
return [self.items count]; | |
} | |
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath | |
{ | |
UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:@"myCell"]; | |
if (!cell) | |
{ | |
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"myCell"]; | |
} | |
cell.textLabel.text = [self.items objectAtIndex:indexPath.row]; | |
return cell; | |
} | |
- (void)viewDidLoad | |
{ | |
[super viewDidLoad]; | |
// Do any additional setup after loading the view, typically from a nib. | |
} | |
- (void)didReceiveMemoryWarning | |
{ | |
[super didReceiveMemoryWarning]; | |
// Dispose of any resources that can be recreated. | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment