Skip to content

Commit a38cf3e

Browse files
committed
Merge branch 'master' into astableview-in-xib
2 parents c81f5d0 + f248dbd commit a38cf3e

7 files changed

Lines changed: 39 additions & 7 deletions

File tree

AsyncDisplayKit/ASCollectionView.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,15 @@
7070
*/
7171
@property (nonatomic, assign) CGFloat leadingScreensForBatching;
7272

73+
/**
74+
* Reload everything from scratch, destroying the working range and all cached nodes.
75+
*
76+
* @param completion block to run on completion of asynchronous loading or nil. If supplied, the block is run on
77+
* the main thread.
78+
* @warning This method is substantially more expensive than UICollectionView's version.
79+
*/
80+
- (void)reloadDataWithCompletion:(void (^)())completion;
81+
7382
/**
7483
* Reload everything from scratch, destroying the working range and all cached nodes.
7584
*

AsyncDisplayKit/ASCollectionView.mm

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,13 +162,18 @@ - (instancetype)initWithFrame:(CGRect)frame collectionViewLayout:(UICollectionVi
162162
#pragma mark -
163163
#pragma mark Overrides.
164164

165-
- (void)reloadData
165+
- (void)reloadDataWithCompletion:(void (^)())completion
166166
{
167167
ASDisplayNodeAssert(self.asyncDelegate, @"ASCollectionView's asyncDelegate property must be set.");
168168
ASDisplayNodePerformBlockOnMainThread(^{
169169
[super reloadData];
170170
});
171-
[_dataController reloadDataWithAnimationOption:kASCollectionViewAnimationNone];
171+
[_dataController reloadDataWithAnimationOption:kASCollectionViewAnimationNone completion:completion];
172+
}
173+
174+
- (void)reloadData
175+
{
176+
[self reloadDataWithCompletion:nil];
172177
}
173178

174179
- (void)setDataSource:(id<UICollectionViewDataSource>)dataSource

AsyncDisplayKit/ASControlNode.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ - (void)addTarget:(id)target action:(SEL)action forControlEvents:(ASControlNodeE
226226
if (!eventDispatchTable)
227227
{
228228
// Create the dispatch table for this event.
229-
eventDispatchTable = [NSMapTable strongToStrongObjectsMapTable];
229+
eventDispatchTable = [NSMapTable weakToStrongObjectsMapTable];
230230
[_controlEventDispatchTable setObject:eventDispatchTable forKey:eventKey];
231231
}
232232

AsyncDisplayKit/ASTableView.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,15 @@
7070
*/
7171
@property (nonatomic, assign) CGFloat leadingScreensForBatching;
7272

73+
/**
74+
* Reload everything from scratch, destroying the working range and all cached nodes.
75+
*
76+
* @param completion block to run on completion of asynchronous loading or nil. If supplied, the block is run on
77+
* the main thread.
78+
* @warning This method is substantially more expensive than UITableView's version.
79+
*/
80+
-(void)reloadDataWithCompletion:(void (^)())completion;
81+
7382
/**
7483
* Reload everything from scratch, destroying the working range and all cached nodes.
7584
*

AsyncDisplayKit/ASTableView.mm

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,13 +217,18 @@ - (void)setAsyncDelegate:(id<ASTableViewDelegate>)asyncDelegate
217217
}
218218
}
219219

220-
- (void)reloadData
220+
- (void)reloadDataWithCompletion:(void (^)())completion
221221
{
222222
ASDisplayNodeAssert(self.asyncDelegate, @"ASTableView's asyncDelegate property must be set.");
223223
ASDisplayNodePerformBlockOnMainThread(^{
224224
[super reloadData];
225225
});
226-
[_dataController reloadDataWithAnimationOption:UITableViewRowAnimationNone];
226+
[_dataController reloadDataWithAnimationOption:UITableViewRowAnimationNone completion:completion];
227+
}
228+
229+
- (void)reloadData
230+
{
231+
[self reloadDataWithCompletion:nil];
227232
}
228233

229234
- (void)setTuningParameters:(ASRangeTuningParameters)tuningParameters forRangeType:(ASLayoutRangeType)rangeType

AsyncDisplayKit/Details/ASDataController.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ typedef NSUInteger ASDataControllerAnimationOptions;
155155

156156
- (void)moveRowAtIndexPath:(NSIndexPath *)indexPath toIndexPath:(NSIndexPath *)newIndexPath withAnimationOption:(ASDataControllerAnimationOptions)animationOption;;
157157

158-
- (void)reloadDataWithAnimationOption:(ASDataControllerAnimationOptions)animationOption;;
158+
- (void)reloadDataWithAnimationOption:(ASDataControllerAnimationOptions)animationOption completion:(void (^)())completion;
159159

160160
/** @name Data Querying */
161161

AsyncDisplayKit/Details/ASDataController.mm

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,7 @@ - (void)moveRowAtIndexPath:(NSIndexPath *)indexPath toIndexPath:(NSIndexPath *)n
437437
});
438438
}
439439

440-
- (void)reloadDataWithAnimationOption:(ASDataControllerAnimationOptions)animationOption
440+
- (void)reloadDataWithAnimationOption:(ASDataControllerAnimationOptions)animationOption completion:(void (^)())completion
441441
{
442442
[self performDataFetchingWithBlock:^{
443443
// Fetching data in calling thread
@@ -478,6 +478,10 @@ - (void)reloadDataWithAnimationOption:(ASDataControllerAnimationOptions)animatio
478478
}];
479479

480480
[self _batchInsertNodes:updatedNodes atIndexPaths:updatedIndexPaths withAnimationOptions:animationOption];
481+
482+
if (completion) {
483+
dispatch_async(dispatch_get_main_queue(), completion);
484+
}
481485
});
482486
}];
483487
}

0 commit comments

Comments
 (0)