mirror of
https://github.com/zhigang1992/RestKit.git
synced 2026-04-28 20:55:32 +08:00
Rename didFinishFinalLoad to didFinalizeLoad for clarity.
This commit is contained in:
@@ -289,7 +289,7 @@ extern NSString* const RKTableControllerDidBecomeOffline;
|
||||
|
||||
/** Sent to the delegate when the controller is really and truly finished loading/updating, whether from the network or from Core Data, or from static data, ... this happens in didFinishLoading
|
||||
**/
|
||||
- (void)tableControllerDidFinishFinalLoad:(RKAbstractTableController *)tableController;
|
||||
- (void)tableControllerDidFinalizeLoad:(RKAbstractTableController *)tableController;
|
||||
|
||||
/**
|
||||
Sent to the delegate when the content of the table view has become empty
|
||||
|
||||
@@ -755,8 +755,9 @@ static NSString* lastUpdatedDateDictionaryKey = @"lastUpdatedDateDictionaryKey";
|
||||
|
||||
[self resetOverlayView];
|
||||
|
||||
if (self.delegate && [_delegate respondsToSelector:@selector(tableControllerDidFinishFinalLoad:)])
|
||||
[_delegate performSelector:@selector(tableControllerDidFinishFinalLoad:)];
|
||||
if (self.delegate && [_delegate respondsToSelector:@selector(tableControllerDidFinalizeLoad:)]) {
|
||||
[_delegate performSelector:@selector(tableControllerDidFinalizeLoad:) withObject:self];
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - Table Overlay Views
|
||||
|
||||
@@ -194,11 +194,12 @@
|
||||
}
|
||||
|
||||
[self.tableView reloadSections:[NSIndexSet indexSetWithIndex:sectionIndex] withRowAnimation:self.defaultRowAnimation];
|
||||
|
||||
// TODO: We should probably not be making this call in cases where we were
|
||||
// loaded via a network API, as we are duplicating cleanup effort that
|
||||
// already exists across our RKRequestDelegate & RKObjectLoaderDelegate methods
|
||||
[self didFinishLoad];
|
||||
|
||||
// The load is finalized via network callbacks for
|
||||
// dynamic table controllers
|
||||
if (nil == self.objectLoader) {
|
||||
[self didFinishLoad];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)loadObjects:(NSArray *)objects {
|
||||
|
||||
@@ -95,6 +95,7 @@
|
||||
- (void)tableController:(RKAbstractTableController*)tableController didDeleteObject:(id)object atIndexPath:(NSIndexPath*)indexPath {}
|
||||
- (void)tableController:(RKAbstractTableController*)tableController willAddSwipeView:(UIView*)swipeView toCell:(UITableViewCell*)cell forObject:(id)object {}
|
||||
- (void)tableController:(RKAbstractTableController*)tableController willRemoveSwipeView:(UIView*)swipeView fromCell:(UITableViewCell*)cell forObject:(id)object {}
|
||||
- (void)tableControllerDidFinalizeLoad:(RKAbstractTableController *)tableController {}
|
||||
|
||||
@end
|
||||
|
||||
@@ -871,6 +872,29 @@
|
||||
STAssertNoThrow([mockDelegate verify], nil);
|
||||
}
|
||||
|
||||
- (void)testNotifyTheDelegateOnDidFinalizeLoad {
|
||||
RKObjectManager* objectManager = [RKTestFactory objectManager];
|
||||
RKTableControllerTestTableViewController* viewController = [RKTableControllerTestTableViewController new];
|
||||
RKTableController* tableController = [RKTableController tableControllerForTableViewController:viewController];
|
||||
tableController.objectManager = objectManager;
|
||||
[tableController mapObjectsWithClass:[RKTestUser class] toTableCellsWithMapping:[RKTableViewCellMapping cellMappingUsingBlock:^(RKTableViewCellMapping* mapping) {
|
||||
mapping.cellClass = [RKTestUserTableViewCell class];
|
||||
[mapping mapKeyPath:@"name" toAttribute:@"textLabel.text"];
|
||||
[mapping mapKeyPath:@"nickName" toAttribute:@"detailTextLabel.text"];
|
||||
}]];
|
||||
RKTestTableControllerDelegate* delegate = [RKTestTableControllerDelegate new];
|
||||
id mockDelegate = [OCMockObject partialMockForObject:delegate];
|
||||
[[mockDelegate expect] tableControllerDidFinalizeLoad:tableController];
|
||||
tableController.delegate = mockDelegate;
|
||||
[tableController loadTableFromResourcePath:@"/JSON/users.json" usingBlock:^(RKObjectLoader* objectLoader) {
|
||||
objectLoader.objectMapping = [RKObjectMapping mappingForClass:[RKTestUser class] usingBlock:^(RKObjectMapping* mapping) {
|
||||
[mapping mapAttributes:@"name", nil];
|
||||
}];
|
||||
}];
|
||||
[mockDelegate waitForLoad];
|
||||
STAssertNoThrow([mockDelegate verify], nil);
|
||||
}
|
||||
|
||||
- (void)testNotifyTheDelegateWhenAnErrorOccurs {
|
||||
RKObjectManager* objectManager = [RKTestFactory objectManager];
|
||||
RKTableControllerTestTableViewController* viewController = [RKTableControllerTestTableViewController new];
|
||||
|
||||
Reference in New Issue
Block a user