Skip to content

Commit f079379

Browse files
author
Carlos
committed
New method to reload the tableView
1 parent d3fd32e commit f079379

2 files changed

Lines changed: 19 additions & 7 deletions

File tree

TLIndexPathTools/Controllers/TLIndexPathController.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -275,8 +275,14 @@ extern NSString * kTLIndexPathUpdatesKey;
275275
*/
276276
@property (copy, nonatomic, nullable) BOOL (^ modificationComparatorBlock)(id item1, id item2);
277277

278-
#pragma mark - Batch updates
279-
/** @name Batch updates */
278+
#pragma mark - Updating
279+
/** @name Updating */
280+
281+
282+
/**
283+
Forces the controller to reload with the current data model.
284+
*/
285+
- (void)update;
280286

281287
/**
282288
Allows for making multiple changes to the controller with only a single

TLIndexPathTools/Controllers/TLIndexPathController.m

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
@interface TLIndexPathController ()
3333
@property (strong, nonatomic) NSFetchedResultsController *backingController;
3434
@property (strong, nonatomic) TLIndexPathDataModel *oldDataModel;
35-
@property (nonatomic) BOOL needsUpdate;
35+
@property (nonatomic) BOOL pendingNeedsUpdate;
3636
@property (nonatomic) BOOL performingBatchUpdate;
3737
@property (nonatomic) BOOL pendingConvertFetchedObjectsToDataModel;
3838
@property (strong, nonatomic) NSMutableArray *updatedItems;
@@ -190,7 +190,7 @@ - (void)setDataModel:(TLIndexPathDataModel *)dataModel
190190

191191
_dataModel = dataModel;
192192

193-
self.needsUpdate = true;
193+
self.pendingNeedsUpdate = true;
194194

195195
[self dequeuePendingUpdates];
196196
}
@@ -199,7 +199,7 @@ - (void)dequeuePendingUpdates
199199
{
200200
//perform udpates immediately unless we're in batch update mode
201201
if (self.performingBatchUpdate || self.isPaused) { return; }
202-
if (!self.needsUpdate) { return; }
202+
if (!self.pendingNeedsUpdate) { return; }
203203
if ([self.delegate respondsToSelector:@selector(controller:willUpdateDataModel:withDataModel:)]) {
204204
TLIndexPathDataModel *dataModel = [self.delegate controller:self willUpdateDataModel:self.oldDataModel withDataModel:self.dataModel];
205205
if (dataModel) {
@@ -218,7 +218,7 @@ - (void)dequeuePendingUpdates
218218
#pragma clang diagnostic pop
219219
[self.updatedItems removeAllObjects];
220220
}
221-
self.needsUpdate = NO;
221+
self.pendingNeedsUpdate = NO;
222222
if ([self.delegate respondsToSelector:@selector(controller:didUpdateDataModel:)] && !self.ignoreDataModelChanges) {
223223
[self.delegate controller:self didUpdateDataModel:updates];
224224
}
@@ -227,7 +227,13 @@ - (void)dequeuePendingUpdates
227227
self.oldDataModel = nil;
228228
}
229229

230-
#pragma mark - Batch updates
230+
#pragma mark - Updating
231+
232+
- (void)update
233+
{
234+
self.pendingNeedsUpdate = YES;
235+
[self dequeuePendingUpdates];
236+
}
231237

232238
- (void)performBatchUpdates:(void (^)(void))updates completion:(void (^)(BOOL))completion
233239
{

0 commit comments

Comments
 (0)