Address comments

This commit is contained in:
Li Tan
2015-02-11 19:15:08 -08:00
parent 6a2c472910
commit 831aa47ae0
8 changed files with 226 additions and 211 deletions

View File

@@ -12,6 +12,7 @@
#import "ViewController.h"
#import <AsyncDisplayKit/AsyncDisplayKit.h>
#import <AsyncDisplayKit/ASAssert.h>
#import "BlurbNode.h"
#import "KittenNode.h"
@@ -25,8 +26,13 @@ static const NSInteger kLitterSize = 20;
// array of boxed CGSizes corresponding to placekitten kittens
NSArray *_kittenDataSource;
BOOL _dataSourceLocked;
}
@property (nonatomic, strong) NSArray *kittenDataSource;
@property (atomic, assign) BOOL dataSourceLocked;
@end
@@ -40,7 +46,7 @@ static const NSInteger kLitterSize = 20;
if (!(self = [super init]))
return nil;
_tableView = [[ASTableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain];
_tableView = [[ASTableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain asyncDataFetching:YES];
_tableView.separatorStyle = UITableViewCellSeparatorStyleNone; // KittenNode has its own separator
_tableView.asyncDataSource = self;
_tableView.asyncDelegate = self;
@@ -59,6 +65,12 @@ static const NSInteger kLitterSize = 20;
return self;
}
- (void)setKittenDataSource:(NSArray *)kittenDataSource {
ASDisplayNodeAssert(!self.dataSourceLocked, @"Could not update data source when it is locked !");
_kittenDataSource = kittenDataSource;
}
- (void)viewDidLoad
{
[super viewDidLoad];
@@ -105,4 +117,12 @@ static const NSInteger kLitterSize = 20;
return NO;
}
- (void)tableViewLockDataSource:(ASTableView *)tableView {
self.dataSourceLocked = YES;
}
- (void)tableViewUnlockDataSource:(ASTableView *)tableView {
self.dataSourceLocked = NO;
}
@end