Skip to content

Instantly share code, notes, and snippets.

@jchudzynski
Created February 4, 2014 21:06
Show Gist options
  • Save jchudzynski/8812384 to your computer and use it in GitHub Desktop.
Save jchudzynski/8812384 to your computer and use it in GitHub Desktop.
Example of complete View Contr
// AlbumListData.m
// Created by Janusz Chudzynski on 3/25/13
#import "AlbumListData.h"
#import "Album.h"
@interface AlbumListData()<UITableViewDelegate, UITableViewDataSource>
@property (nonatomic,weak) UITableView * tableView;
@property (nonatomic,strong) NSArray * objects;
@end
@implementation AlbumListData
#pragma mark - Table view data source
// Return the number of sections.
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}
/*
Number of the rows in the section
*/
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return self.objects.count;
}
/*
Controlling look of the cell
*/
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"AlbumCell"];
if(cell == nil) {
cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"AlbumCell"];
}
Album * album = (Album *)self.objects[indexPath.row];
cell.textLabel.text =album.name;
cell.imageView.image = [UIImage imageNamed:@"albumSmallIcon"];
return cell;
}
/*
Managing Selections
*/
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment