@@ -264,31 +264,33 @@ @implementation SRGTableViewReactiveAdapter
264264- (instancetype )initWithTableView : (UITableView *)tableView
265265 withInitialState : (NSArray *)array {
266266 self = [super init ];
267- self.tableView = tableView;
268-
269- self.dataSource = self.tableView .dataSource ;
270- self.tableView .dataSource = self;
271-
272- self.flushCommand = [[RACCommand alloc ] initWithSignalBlock: ^RACSignal *(id input) {
273- return [RACSignal createSignal: ^RACDisposable *(id <RACSubscriber> subscriber) {
274- [self processTableViewFlush ];
275- // since flushCommand has concurrentExecution turned off, this delay will
276- // ensure flush is performed not more frequent than this delay. (so tableView can finish it's animations safely)
277- [[RACScheduler mainThreadScheduler ] afterDelay: .33 schedule: ^{
278- [subscriber sendCompleted ];
267+ if (self) {
268+ self.tableView = tableView;
269+
270+ self.dataSource = self.tableView .dataSource ;
271+ self.tableView .dataSource = self;
272+
273+ self.flushCommand = [[RACCommand alloc ] initWithSignalBlock: ^RACSignal *(id input) {
274+ return [RACSignal createSignal: ^RACDisposable *(id <RACSubscriber> subscriber) {
275+ [self processTableViewFlush ];
276+ // since flushCommand has concurrentExecution turned off, this delay will
277+ // ensure flush is performed not more frequent than this delay. (so tableView can finish it's animations safely)
278+ [[RACScheduler mainThreadScheduler ] afterDelay: .33 schedule: ^{
279+ [subscriber sendCompleted ];
280+ }];
281+ return nil ;
279282 }];
280- return nil ;
281283 }];
282- }];
283- self.sourceEventsSignal = [RACSubject subject ];
284-
285- NSMutableArray *arr = [NSMutableArray array ];
286- for (NSArray *innerArr in array) {
287- [arr addObject: innerArr.mutableCopy];
284+ self.sourceEventsSignal = [RACSubject subject ];
285+
286+ NSMutableArray *arr = [NSMutableArray array ];
287+ for (NSArray *innerArr in array) {
288+ [arr addObject: innerArr.mutableCopy];
289+ }
290+ self.tableViewSource = arr;
291+ self.intermediateState = [[SRGTableViewIntermediateState alloc ] initWithInitialState: self .tableViewSource];
292+ [self initRelations ];
288293 }
289- self.tableViewSource = arr;
290- self.intermediateState = [[SRGTableViewIntermediateState alloc ] initWithInitialState: self .tableViewSource];
291- [self initRelations ];
292294 return self;
293295}
294296
0 commit comments