Permalink
Browse files

Cancel current object loader when loading a table view

  • Loading branch information...
1 parent 9ca2ba2 commit 86ac03895707ba57ec6ec0a4b9909156aa750004 @blakewatters blakewatters committed May 21, 2012
@@ -197,6 +197,7 @@ - (void)dealloc {
// TODO: WTF? Get UI crashes when enabled...
// [_objectManager.requestQueue abortRequestsWithDelegate:self];
_objectLoader.delegate = nil;
+ [_objectLoader release];
_objectLoader = nil;
[_sections release];
@@ -741,7 +742,7 @@ - (void)objectLoaderDidFinishLoading:(RKObjectLoader *)objectLoader {
[self.delegate tableController:self didLoadTableWithObjectLoader:objectLoader];
}
- [self.objectLoader reset];
+ [objectLoader reset];
[self didFinishLoad];
}
@@ -1347,6 +1348,11 @@ - (void)resizeTableViewForKeyboard:(NSNotification*)notification {
- (void)loadTableWithObjectLoader:(RKObjectLoader*)theObjectLoader {
NSAssert(theObjectLoader, @"Cannot perform a network load without an object loader");
if (! [self.objectLoader isEqual:theObjectLoader]) {
+ if (self.objectLoader) {
+ RKLogDebug(@"Cancelling in progress table load: asked to load with a new object loader.");
+ [self.objectLoader.queue cancelRequest:self.objectLoader];
+ }
+
theObjectLoader.delegate = self;
self.objectLoader = theObjectLoader;
}
@@ -541,13 +541,11 @@ - (void)testFireADeleteRequestWhenTheCanEditRowsPropertyIsSet {
canEditRowAtIndexPath:deleteIndexPath];
assertThatBool(delegateCanEdit, is(equalToBool(YES)));
-// RKTestNotificationObserver* observer = [RKTestNotificationObserver notificationObserverForNotificationName:RKRequestDidLoadResponseNotification];
[RKTestNotificationObserver waitForNotificationWithName:RKRequestDidLoadResponseNotification usingBlock:^{
[tableController tableView:tableController.tableView
commitEditingStyle:UITableViewCellEditingStyleDelete
forRowAtIndexPath:deleteIndexPath];
}];
-// observer.timeout = 30;
assertThatInt([tableController rowCount], is(equalToInt(1)));
assertThat([tableController objectForRowAtIndexPath:deleteIndexPath], is(equalTo(other)));
@@ -764,7 +764,7 @@ - (void)testExitTheLoadingStateWhenTheRequestFinishesLoading {
RKTableController* tableController = [RKTableController tableControllerForTableViewController:viewController];
assertThatBool([tableController isLoaded], is(equalToBool(NO)));
assertThatBool([tableController isLoading], is(equalToBool(NO)));
- id mockLoader = [OCMockObject mockForClass:[RKObjectLoader class]];
+ id mockLoader = [OCMockObject niceMockForClass:[RKObjectLoader class]];
[tableController requestDidStartLoad:mockLoader];
assertThatBool([tableController isLoading], is(equalToBool(YES)));
[tableController objectLoaderDidFinishLoading:mockLoader];

0 comments on commit 86ac038

Please sign in to comment.