Skip to content

Commit e464d28

Browse files
committed
Add support for specifying a custom RKHTTPRequestOperation class
1 parent 71ea7a2 commit e464d28

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

Code/RKAbstractTableController.h

+1
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ typedef NSInteger RKTableControllerState;
173173
@property (nonatomic, strong) NSOperationQueue *operationQueue;
174174
@property (nonatomic, strong) NSArray *responseDescriptors;
175175

176+
- (void)setHTTPOperationClass:(Class)operationClass;
176177
- (void)loadTableWithRequest:(NSURLRequest *)request;
177178
- (void)cancelLoad;
178179

Code/RKAbstractTableController.m

+8
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,8 @@ @interface RKAbstractTableController ()
9090

9191
@property (nonatomic, strong) RKKeyboardScroller *keyboardScroller;
9292
@property (nonatomic, copy) void (^failureBlock)(NSError *error);
93+
@property (nonatomic, strong) Class HTTPOperationClass;
94+
9395
@end
9496

9597
@implementation RKAbstractTableController
@@ -620,8 +622,14 @@ - (NSIndexPath *)tableView:(UITableView *)tableView willSelectRowAtIndexPath:(NS
620622

621623
#pragma mark - Network Table Loading
622624

625+
- (Class)HTTPOperationClass
626+
{
627+
return _HTTPOperationClass ?: [RKHTTPRequestOperation class];
628+
}
629+
623630
- (id)objectRequestOperationWithRequest:(NSURLRequest *)request
624631
{
632+
RKHTTPRequestOperation *requestOperation = [[[self HTTPOperationClass] alloc] initWithRequest:request];
625633
return [[RKObjectRequestOperation alloc] initWithRequest:request responseDescriptors:self.responseDescriptors];
626634
}
627635

Code/RKFetchedResultsTableController.m

+4-1
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ @interface RKFetchedResultsTableController ()
5151
@property (nonatomic, strong, readwrite) NSFetchedResultsController *fetchedResultsController;
5252
@property (nonatomic, strong) NSArray *arraySortedFetchedObjects;
5353
@property (nonatomic, assign, getter = hasRequestChanged) BOOL requestChanged;
54+
@property (nonatomic, readonly) Class HTTPOperationClass;
5455

5556
- (BOOL)performFetch:(NSError **)error;
5657
- (void)updateSortedArray;
@@ -59,6 +60,7 @@ - (void)updateSortedArray;
5960
@implementation RKFetchedResultsTableController
6061

6162
@dynamic delegate;
63+
@dynamic HTTPOperationClass;
6264

6365
- (id)initWithTableView:(UITableView *)tableView viewController:(UIViewController *)viewController
6466
{
@@ -258,7 +260,8 @@ - (NSFetchRequest *)fetchRequest
258260

259261
- (id)objectRequestOperationWithRequest:(NSURLRequest *)request
260262
{
261-
RKManagedObjectRequestOperation *operation = [[RKManagedObjectRequestOperation alloc] initWithRequest:request responseDescriptors:self.responseDescriptors];
263+
RKHTTPRequestOperation *requestOperation = [[[self HTTPOperationClass] alloc] initWithRequest:request];
264+
RKManagedObjectRequestOperation *operation = [[RKManagedObjectRequestOperation alloc] initWithHTTPRequestOperation:requestOperation responseDescriptors:self.responseDescriptors];
262265
operation.managedObjectContext = self.managedObjectContext;
263266
operation.fetchRequestBlocks = self.fetchRequestBlocks;
264267
operation.managedObjectCache = self.managedObjectCache;

0 commit comments

Comments
 (0)