Created
November 18, 2015 16:31
-
-
Save rogerluan/d8e62386521b138b7db2 to your computer and use it in GitHub Desktop.
Code snippet for blog series.
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
//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