TableViewAgent
library that wraps the delegate and datesource of UITableView
Installation
CocoaPods
pod 'TableViewAgent'
Usage
- used
dequeueReusableCellWithIdentifier:
UITableView to return the instance - implement
setViewObject:
to returned the instance - Declare an member variable of the TableViewAgent
- TableViewAgent setting in
viewDidload
- implement
cellIdentifier:
to viewController
@implementation CustomViewController {
TableViewAgent *agent;
}
- (void)viewDidLoad {
[super viewDidLoad];
agent = [[TableViewAgent alloc] init];
agent.viewObjects = [[FRCAgentViewObject alloc] initWithFetch:fetchResultController];
agent.delegate = self;
}
- (NSString *)cellIdentifier:(id)viewObject {
return @"Cell";
}
@end
@implementation CustomTableViewCell
- (void)setViewObject:(Model *)model {
self.textLabel.text = model.text;
}
@end
Idea
UITableView is a view for displaying a particular set. The set always be defined a unique order, are sometimes grouped. The number of sets equal to the number of TableViewCell. Each elements of set holds enough information to draw TableViewCell. Since each element is independent, the interaction is not present in the Cell (interactions in Cell or without).
Each element is mapped to Cell. When mapping, setViewObject:
element is sent to the TableViewCell by a message. Display methods and change the Cell is the responsibility. Although Cell is selected by the content of the element, it is, cellIdentifier:
by is performed.
Contributing
- Fork it!
- Create your feature branch:
git checkout -b my-new-feature
- Commit your changes:
git commit -am 'Add some feature'
- Push to the branch:
git push origin my-new-feature
- Submit a pull request :D
License
MIT