Skip to content

Instantly share code, notes, and snippets.

@rogerluan
Created November 18, 2015 16:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rogerluan/d8e62386521b138b7db2 to your computer and use it in GitHub Desktop.
Save rogerluan/d8e62386521b138b7db2 to your computer and use it in GitHub Desktop.
Code snippet for blog series.
//TableCoordinator.h
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
@interface TableCoordinator : NSObject
@property (nonatomic, strong) IBOutlet UITableView *tableView;
- (void)reloadData:(NSArray *)data;
@end
//TableCoordinator.m
#import "TableCoordinator.h"
#import "TableDataSource.h"
#import "TableDelegate.h"
#import "CustomTableViewCell.h"
@interface TableCoordinator ()
@property (nonatomic, strong) IBOutlet TableDataSource *dataSource;
@property (nonatomic, strong) IBOutlet TableDelegate *delegate;
@end
@implementation TableCoordinator
- (void)awakeFromNib {
[super awakeFromNib];
// [self registerCells];
}
- (void)reloadData:(NSArray *)data {
self.dataSource.data = data;
self.delegate.data = data;
[self.tableView reloadData];
}
/**
*
* Se você for utilizar nibs ao invés de storyboard, precisará registrar suas cells para reutilizá-las. Note que isso será necessário sempre, independente de estar utilizando essas classes especiais ou não. No início do projeto, isso estaria (mal)localizado na classe TableViewController, e sendo chamado dentro do viewDidload, caso contrário suas células não mostrarão conteúdo algum.
*/
//- (void) registerCells {
// UINib *nib = [UINib nibWithNibName:@"nome_da_sua_nib" bundle:nil];
// [self.tableView registerNib:nib forCellReuseIdentifier:@"identifier_da_sua_cell"];
//}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment