Skip to content

Commit

Permalink
Deprecated RKObjectManager methods that use queryParams. Added NSStri…
Browse files Browse the repository at this point in the history
…ng category for achieving the same results without bloating the API
  • Loading branch information
blakewatters committed Jun 16, 2011
1 parent e3a007f commit a75ace8
Show file tree
Hide file tree
Showing 5 changed files with 80 additions and 3 deletions.
9 changes: 6 additions & 3 deletions Code/ObjectMapping/RKObjectManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -187,13 +187,16 @@ typedef enum {
Create and send an asynchronous GET request to load the objects at the specified resource path with a dictionary
of query parameters to append to the URL and call back the delegate with the loaded objects. Remote objects will be mapped to
local objects by consulting the element registrations set on the mapper.
These methods have been deprecated. You can use [resourcePath appendQueryParams:queryParams] to achieve the same effect.
@deprecated
*/
// TODO: Deprecate! Just RKPathAppendQueryParams(resourcePath, queryParams)
- (RKObjectLoader*)loadObjectsAtResourcePath:(NSString *)resourcePath queryParams:(NSDictionary*)queryParams delegate:(id<RKObjectLoaderDelegate>)delegate;
- (RKObjectLoader*)loadObjectsAtResourcePath:(NSString *)resourcePath queryParams:(NSDictionary*)queryParams delegate:(id<RKObjectLoaderDelegate>)delegate DEPRECATED_ATTRIBUTE;
- (RKObjectLoader*)loadObjectsAtResourcePath:(NSString *)resourcePath queryParams:(NSDictionary*)queryParams objectMapping:(RKObjectMapping*)objectMapping delegate:(id<RKObjectLoaderDelegate>)delegate DEPRECATED_ATTRIBUTE;

// TODO: Document!
- (RKObjectLoader*)loadObjectsAtResourcePath:(NSString*)resourcePath objectMapping:(RKObjectMapping*)objectMapping delegate:(id<RKObjectLoaderDelegate>)delegate;
- (RKObjectLoader*)loadObjectsAtResourcePath:(NSString *)resourcePath queryParams:(NSDictionary*)queryParams objectMapping:(RKObjectMapping*)objectMapping delegate:(id<RKObjectLoaderDelegate>)delegate;

////////////////////////////////////////////////////////
/// @name Mappable object helpers
Expand Down
43 changes: 43 additions & 0 deletions Code/Support/NSString+RestKit.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
//
// NSString+RestKit.h
// RestKit
//
// Created by Blake Watters on 6/15/11.
// Copyright 2011 Two Toasters. All rights reserved.
//

#import <Foundation/Foundation.h>

/**
A library of helpful additions to the NSString class to simplify
common tasks within RestKit
*/
@interface NSString (NSString)

/**
Returns a resource path with a dictionary of query parameters URL encoded and appended
This is a convenience method for constructing a new resource path that includes a query. For example,
when given a resourcePath of /contacts and a dictionary of parameters containing foo=bar and color=red,
will return /contacts?foo=bar&color=red
*NOTE* - Assumes that the resource path does not already contain any query parameters.
@param queryParams A dictionary of query parameters to be URL encoded and appended to the resource path
@return A new resource path with the query parameters appended
@see RKPathAppendQueryParams
*/
- (NSString*)appendQueryParams:(NSDictionary*)queryParams;

/**
Convenience method for generating a path against the properties of an object. Takes
a string with property names encoded in parentheses and interpolates the values of
the properties specified and returns the generated path.
For example, given an 'article' object with an 'articleID' property of 12345
[@"articles/(articleID)" interpolateWithObject:article] would generate @"articles/12345"
This functionality is the basis for resource path generation in the Router.
@param object The object to interpolate the properties against
*/
- (NSString*)interpolateWithObject:(id)object;

@end
22 changes: 22 additions & 0 deletions Code/Support/NSString+RestKit.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
//
// NSString+RestKit.m
// RestKit
//
// Created by Blake Watters on 6/15/11.
// Copyright 2011 Two Toasters. All rights reserved.
//

#import "NSString+RestKit.h"
#import "../Network/RKClient.h"

@implementation NSString (RestKit)

- (NSString*)appendQueryParams:(NSDictionary*)queryParams {
return RKPathAppendQueryParams(self, queryParams);
}

- (NSString*)interpolateWithObject:(id)object {
return RKMakePathWithObject(self, object);
}

@end
1 change: 1 addition & 0 deletions Code/Support/Support.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@
#import "NSDictionary+RKAdditions.h"
#import "RKMIMETypes.h"
#import "RKLog.h"
#import "NSString+RestKit.h"
8 changes: 8 additions & 0 deletions RestKit.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@
250D5C0213A069EA00471F0E /* lcl_config_extensions.h in Headers */ = {isa = PBXBuildFile; fileRef = 250D5C0113A069EA00471F0E /* lcl_config_extensions.h */; settings = {ATTRIBUTES = (Public, ); }; };
250D5C0413A06A4D00471F0E /* lcl_config_logger.h in Headers */ = {isa = PBXBuildFile; fileRef = 250D5C0313A06A4D00471F0E /* lcl_config_logger.h */; settings = {ATTRIBUTES = (Public, ); }; };
251899FC1370F4E00092B049 /* RKLog.h in Headers */ = {isa = PBXBuildFile; fileRef = 251899FB1370F4E00092B049 /* RKLog.h */; settings = {ATTRIBUTES = (Public, ); }; };
251939B613A94B670073A39B /* NSString+RestKit.h in Headers */ = {isa = PBXBuildFile; fileRef = 251939B213A94B5F0073A39B /* NSString+RestKit.h */; settings = {ATTRIBUTES = (Public, ); }; };
251939B713A94B670073A39B /* NSString+RestKit.m in Sources */ = {isa = PBXBuildFile; fileRef = 251939B313A94B5F0073A39B /* NSString+RestKit.m */; };
251D14AC133597B800959061 /* RKManagedObjectLoader.h in Headers */ = {isa = PBXBuildFile; fileRef = 251D14AA133597B800959061 /* RKManagedObjectLoader.h */; settings = {ATTRIBUTES = (Public, ); }; };
251D14AD133597B800959061 /* RKManagedObjectLoader.m in Sources */ = {isa = PBXBuildFile; fileRef = 251D14AB133597B800959061 /* RKManagedObjectLoader.m */; };
2523363E11E7A1F00048F9B4 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3F6C3A9510FE7524008F47C5 /* UIKit.framework */; };
Expand Down Expand Up @@ -387,6 +389,8 @@
250D5C0113A069EA00471F0E /* lcl_config_extensions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = lcl_config_extensions.h; sourceTree = "<group>"; };
250D5C0313A06A4D00471F0E /* lcl_config_logger.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = lcl_config_logger.h; sourceTree = "<group>"; };
251899FB1370F4E00092B049 /* RKLog.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RKLog.h; sourceTree = "<group>"; };
251939B213A94B5F0073A39B /* NSString+RestKit.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSString+RestKit.h"; sourceTree = "<group>"; };
251939B313A94B5F0073A39B /* NSString+RestKit.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSString+RestKit.m"; sourceTree = "<group>"; };
251D14AA133597B800959061 /* RKManagedObjectLoader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RKManagedObjectLoader.h; sourceTree = "<group>"; };
251D14AB133597B800959061 /* RKManagedObjectLoader.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RKManagedObjectLoader.m; sourceTree = "<group>"; };
2523360511E79F090048F9B4 /* libRestKitThree20.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libRestKitThree20.a; sourceTree = BUILT_PRODUCTS_DIR; };
Expand Down Expand Up @@ -1017,6 +1021,8 @@
250D5C0113A069EA00471F0E /* lcl_config_extensions.h */,
250D5C0313A06A4D00471F0E /* lcl_config_logger.h */,
253A09F512552BDC00976E89 /* Support.h */,
251939B213A94B5F0073A39B /* NSString+RestKit.h */,
251939B313A94B5F0073A39B /* NSString+RestKit.m */,
);
path = Support;
sourceTree = "<group>";
Expand Down Expand Up @@ -1476,6 +1482,7 @@
250D5C0013A069C400471F0E /* lcl_config_components.h in Headers */,
250D5C0213A069EA00471F0E /* lcl_config_extensions.h in Headers */,
250D5C0413A06A4D00471F0E /* lcl_config_logger.h in Headers */,
251939B613A94B670073A39B /* NSString+RestKit.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -1948,6 +1955,7 @@
250D5BF113A0698100471F0E /* lcl.m in Sources */,
250D5BFB13A0698100471F0E /* LCLNSLog.m in Sources */,
25DBB3A113A2486400CE90F1 /* RKLog.m in Sources */,
251939B713A94B670073A39B /* NSString+RestKit.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down

0 comments on commit a75ace8

Please sign in to comment.