Skip to content

Commit

Permalink
Added category introducing convenience methods for initializing table…
Browse files Browse the repository at this point in the history
… controller from the object manager
  • Loading branch information
blakewatters committed Feb 24, 2012
1 parent c779462 commit 07a18a7
Show file tree
Hide file tree
Showing 4 changed files with 116 additions and 0 deletions.
60 changes: 60 additions & 0 deletions Code/UI/RKObjectManager+RKTableController.h
@@ -0,0 +1,60 @@
//
// RKObjectManager+RKTableController.h
// RestKit
//
// Created by Blake Watters on 2/23/12.
// Copyright (c) 2012 RestKit. All rights reserved.
//

#import "RKObjectManager.h"

#ifdef TARGET_OS_IPHONE

@class RKTableController, RKFetchedResultsTableController;

/**
Provides extensions to RKObjectManager for instantiating RKTableController instances
*/
@interface RKObjectManager (RKTableController)

/**
Creates and returns a table controller object capable of loading remote object representations
into a UITableView using the RestKit object mapping engine for a given table view controller.
@param tableViewController A UITableViewController to instantiate a table controller for
@return An RKTableController instance ready to drive the table view for the provided tableViewController.
*/
- (RKTableController *)tableControllerForTableViewController:(UITableViewController *)tableViewController;

/**
Creates and returns a table controller object capable of loading remote object representations
into a UITableView using the RestKit object mapping engine for a given table view and view controller.
@param tableView The UITableView object that table controller with acts as the delegate and data source for.
@param viewController The UIViewController that owns the specified tableView.
@return An RKTableController instance ready to drive the table view for the provided tableViewController.
*/
- (RKTableController *)tableControllerWithTableView:(UITableView *)tableView forViewController:(UIViewController *)viewController;

/**
Creates and returns a fetched results table controller object capable of loading remote object representations
stored in Core Data into a UITableView using the RestKit object mapping engine for a given table view controller.
@param tableViewController A UITableViewController to instantiate a table controller for
@return An RKFetchedResultsTableController instance ready to drive the table view for the provided tableViewController.
*/
- (RKFetchedResultsTableController *)fetchedResultsTableControllerForTableViewController:(UITableViewController *)tableViewController;

/**
Creates and returns a table controller object capable of loading remote object representations
stored in Core Data into a UITableView using the RestKit object mapping engine for a given table view and view controller.
@param tableView The UITableView object that table controller with acts as the delegate and data source for.
@param viewController The UIViewController that owns the specified tableView.
@return An RKFetchedResultsTableController instance ready to drive the table view for the provided tableViewController.
*/
- (RKFetchedResultsTableController *)fetchedResultsTableControllerWithTableView:(UITableView *)tableView forViewController:(UIViewController *)viewController;

@end

#endif
43 changes: 43 additions & 0 deletions Code/UI/RKObjectManager+RKTableController.m
@@ -0,0 +1,43 @@
//
// RKObjectManager+RKTableController.m
// RestKit
//
// Created by Blake Watters on 2/23/12.
// Copyright (c) 2012 RestKit. All rights reserved.
//

#import "RKObjectManager+RKTableController.h"

#ifdef TARGET_OS_IPHONE

#import "RKTableController.h"
#import "RKFetchedResultsTableController.h"

@implementation RKObjectManager (RKTableController)

- (RKTableController *)tableControllerForTableViewController:(UITableViewController *)tableViewController {
RKTableController *tableController = [RKTableController tableControllerForTableViewController:tableViewController];
tableController.objectManager = self;
return tableController;
}

- (RKTableController *)tableControllerWithTableView:(UITableView *)tableView forViewController:(UIViewController *)viewController {
RKTableController *tableController = [RKTableController tableControllerWithTableView:tableView forViewController:viewController];
tableController.objectManager = self;
return tableController;
}

- (RKFetchedResultsTableController *)fetchedResultsTableControllerForTableViewController:(UITableViewController *)tableViewController {
RKFetchedResultsTableController *tableController = [RKFetchedResultsTableController tableControllerForTableViewController:tableViewController];
tableController.objectManager = self;
return tableController;
}

- (RKFetchedResultsTableController *)fetchedResultsTableControllerWithTableView:(UITableView *)tableView forViewController:(UIViewController *)viewController {
RKFetchedResultsTableController *tableController = [RKFetchedResultsTableController tableControllerWithTableView:tableView forViewController:viewController];
return tableController;
}

@end

#endif
1 change: 1 addition & 0 deletions Code/UI/UI.h
Expand Up @@ -29,5 +29,6 @@
#import "RKForm.h"
#import "RKFormSection.h"
#import "RKTableView.h"
#import "RKObjectManager+RKTableController.h"

#endif
12 changes: 12 additions & 0 deletions RestKit.xcodeproj/project.pbxproj
Expand Up @@ -629,6 +629,10 @@
25CA7A8F14EC570200888FF8 /* RKObjectMappingDefinition.m in Sources */ = {isa = PBXBuildFile; fileRef = 25CA7A8E14EC570100888FF8 /* RKObjectMappingDefinition.m */; };
25CA7A9014EC570200888FF8 /* RKObjectMappingDefinition.m in Sources */ = {isa = PBXBuildFile; fileRef = 25CA7A8E14EC570100888FF8 /* RKObjectMappingDefinition.m */; };
25CA7A9114EC5C2D00888FF8 /* RKTestFixture.m in Sources */ = {isa = PBXBuildFile; fileRef = 252EFB2114D9B35D004863C8 /* RKTestFixture.m */; };
25EC1A2C14F6FDAD00C3CF3F /* RKObjectManager+RKTableController.h in Headers */ = {isa = PBXBuildFile; fileRef = 25EC1A2A14F6FDAC00C3CF3F /* RKObjectManager+RKTableController.h */; settings = {ATTRIBUTES = (Public, ); }; };
25EC1A2D14F6FDAD00C3CF3F /* RKObjectManager+RKTableController.h in Headers */ = {isa = PBXBuildFile; fileRef = 25EC1A2A14F6FDAC00C3CF3F /* RKObjectManager+RKTableController.h */; settings = {ATTRIBUTES = (Public, ); }; };
25EC1A2E14F6FDAD00C3CF3F /* RKObjectManager+RKTableController.m in Sources */ = {isa = PBXBuildFile; fileRef = 25EC1A2B14F6FDAC00C3CF3F /* RKObjectManager+RKTableController.m */; };
25EC1A2F14F6FDAD00C3CF3F /* RKObjectManager+RKTableController.m in Sources */ = {isa = PBXBuildFile; fileRef = 25EC1A2B14F6FDAC00C3CF3F /* RKObjectManager+RKTableController.m */; };
25FABED014E3796400E609E7 /* RKTestNotificationObserver.m in Sources */ = {isa = PBXBuildFile; fileRef = 252EFAFD14D8EB30004863C8 /* RKTestNotificationObserver.m */; };
25FABED114E3796400E609E7 /* RKTestNotificationObserver.m in Sources */ = {isa = PBXBuildFile; fileRef = 252EFAFD14D8EB30004863C8 /* RKTestNotificationObserver.m */; };
25FABED214E3796B00E609E7 /* RKTestNotificationObserver.h in Headers */ = {isa = PBXBuildFile; fileRef = 252EFAFC14D8EB30004863C8 /* RKTestNotificationObserver.h */; settings = {ATTRIBUTES = (Public, ); }; };
Expand Down Expand Up @@ -1089,6 +1093,8 @@
25B6EA0514CF946300B1E881 /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = System/Library/Frameworks/QuartzCore.framework; sourceTree = SDKROOT; };
25B6EA0714CF947D00B1E881 /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; };
25CA7A8E14EC570100888FF8 /* RKObjectMappingDefinition.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RKObjectMappingDefinition.m; sourceTree = "<group>"; };
25EC1A2A14F6FDAC00C3CF3F /* RKObjectManager+RKTableController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "RKObjectManager+RKTableController.h"; sourceTree = "<group>"; };
25EC1A2B14F6FDAC00C3CF3F /* RKObjectManager+RKTableController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "RKObjectManager+RKTableController.m"; sourceTree = "<group>"; };
25FABED414E37A2B00E609E7 /* RKTestResponseLoader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RKTestResponseLoader.h; path = Testing/RKTestResponseLoader.h; sourceTree = "<group>"; };
25FABED514E37A2B00E609E7 /* RKTestResponseLoader.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = RKTestResponseLoader.m; path = Testing/RKTestResponseLoader.m; sourceTree = "<group>"; };
49A66B0814CEFB0400A6F062 /* LICENCE */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = LICENCE; path = XMLReader/LICENCE; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1864,6 +1870,8 @@
25B6E91B14CF778D00B1E881 /* UI.h */,
25B6E91C14CF778D00B1E881 /* UIView+FindFirstResponder.h */,
25B6E91D14CF778D00B1E881 /* UIView+FindFirstResponder.m */,
25EC1A2A14F6FDAC00C3CF3F /* RKObjectManager+RKTableController.h */,
25EC1A2B14F6FDAC00C3CF3F /* RKObjectManager+RKTableController.m */,
);
path = UI;
sourceTree = "<group>";
Expand Down Expand Up @@ -2106,6 +2114,7 @@
25055B8414EEF32A00B9C4DD /* RKMappingTest.h in Headers */,
25055B8814EEF32A00B9C4DD /* RKTestFactory.h in Headers */,
25055B8F14EEF40000B9C4DD /* RKMappingTestExpectation.h in Headers */,
25EC1A2C14F6FDAD00C3CF3F /* RKObjectManager+RKTableController.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -2215,6 +2224,7 @@
25055B8514EEF32A00B9C4DD /* RKMappingTest.h in Headers */,
25055B8914EEF32A00B9C4DD /* RKTestFactory.h in Headers */,
25055B9014EEF40000B9C4DD /* RKMappingTestExpectation.h in Headers */,
25EC1A2D14F6FDAD00C3CF3F /* RKObjectManager+RKTableController.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -2564,6 +2574,7 @@
25055B8614EEF32A00B9C4DD /* RKMappingTest.m in Sources */,
25055B8A14EEF32A00B9C4DD /* RKTestFactory.m in Sources */,
25055B9114EEF40000B9C4DD /* RKMappingTestExpectation.m in Sources */,
25EC1A2E14F6FDAD00C3CF3F /* RKObjectManager+RKTableController.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -2729,6 +2740,7 @@
25055B8714EEF32A00B9C4DD /* RKMappingTest.m in Sources */,
25055B8B14EEF32A00B9C4DD /* RKTestFactory.m in Sources */,
25055B9214EEF40000B9C4DD /* RKMappingTestExpectation.m in Sources */,
25EC1A2F14F6FDAD00C3CF3F /* RKObjectManager+RKTableController.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down

0 comments on commit 07a18a7

Please sign in to comment.