diff --git a/Code/Network/RKClient.h b/Code/Network/RKClient.h index 325c710a..b6f238eb 100644 --- a/Code/Network/RKClient.h +++ b/Code/Network/RKClient.h @@ -478,7 +478,7 @@ NSString *RKPathAppendQueryParams(NSString *resourcePath, NSDictionary *queryPar @see baseURL @return A configured RKClient instance ready to send requests */ -+ (RKClient *)clientWithBaseURL:(RKURL *)baseURL; ++ (RKClient *)clientWithBaseURL:(NSURL *)baseURL; + (RKClient *)clientWithBaseURLString:(NSString *)baseURLString; /** @@ -499,7 +499,7 @@ NSString *RKPathAppendQueryParams(NSString *resourcePath, NSDictionary *queryPar @see baseURL @return A configured RKClient instance ready to send requests */ -- (id)initWithBaseURL:(RKURL *)baseURL; +- (id)initWithBaseURL:(NSURL *)baseURL; - (id)initWithBaseURLString:(NSString *)baseURLString; ///////////////////////////////////////////////////////////////////////// diff --git a/Code/Network/RKClient.m b/Code/Network/RKClient.m index 56865c3b..413ffc36 100644 --- a/Code/Network/RKClient.m +++ b/Code/Network/RKClient.m @@ -102,7 +102,7 @@ NSString *RKPathAppendQueryParams(NSString *resourcePath, NSDictionary *queryPar return [self clientWithBaseURL:[RKURL URLWithString:baseURLString]]; } -+ (RKClient *)clientWithBaseURL:(RKURL *)baseURL { ++ (RKClient *)clientWithBaseURL:(NSURL *)baseURL { RKClient *client = [[[self alloc] initWithBaseURL:baseURL] autorelease]; return client; } @@ -139,11 +139,11 @@ NSString *RKPathAppendQueryParams(NSString *resourcePath, NSDictionary *queryPar return self; } -- (id)initWithBaseURL:(RKURL *)baseURL { +- (id)initWithBaseURL:(NSURL *)baseURL { self = [self init]; if (self) { self.cachePolicy = RKRequestCachePolicyDefault; - self.baseURL = baseURL; + self.baseURL = [RKURL URLWithBaseURL:baseURL]; if (sharedClient == nil) { [RKClient setSharedClient:self]; diff --git a/Code/ObjectMapping/RKObjectLoader.m b/Code/ObjectMapping/RKObjectLoader.m index b0f93677..30f7628d 100644 --- a/Code/ObjectMapping/RKObjectLoader.m +++ b/Code/ObjectMapping/RKObjectLoader.m @@ -29,6 +29,7 @@ #import "RKParserRegistry.h" #import "RKRequest_Internals.h" #import "RKObjectSerializer.h" +#import "RKObjectMappingProvider+Contexts.h" // Set Logging Component #undef RKLogComponent diff --git a/Code/ObjectMapping/RKObjectManager.h b/Code/ObjectMapping/RKObjectManager.h index 6748e9dd..4522a479 100644 --- a/Code/ObjectMapping/RKObjectManager.h +++ b/Code/ObjectMapping/RKObjectManager.h @@ -135,9 +135,8 @@ typedef enum { Create and initialize a new object manager. If this is the first instance created it will be set as the shared instance */ -// TODO: Both of these should be `managerWith` instead of `objectManagerWith` -+ (RKObjectManager*)objectManagerWithBaseURLString:(NSString *)baseURLString; -+ (RKObjectManager*)objectManagerWithBaseURL:(RKURL *)baseURL; ++ (RKObjectManager*)managerWithBaseURLString:(NSString *)baseURLString; ++ (RKObjectManager*)managerWithBaseURL:(NSURL *)baseURL; /** Initializes a newly created object manager with a specified baseURL. @@ -431,6 +430,8 @@ typedef enum { - (RKObjectPaginator *)paginatorWithResourcePathPattern:(NSString *)resourcePathPattern; ++ (RKObjectManager*)objectManagerWithBaseURLString:(NSString *)baseURLString; ++ (RKObjectManager*)objectManagerWithBaseURL:(NSURL *)baseURL; - (RKObjectLoader*)objectLoaderWithResourcePath:(NSString*)resourcePath delegate:(id)delegate DEPRECATED_ATTRIBUTE; - (RKObjectLoader*)objectLoaderForObject:(id)object method:(RKRequestMethod)method delegate:(id)delegate DEPRECATED_ATTRIBUTE; diff --git a/Code/ObjectMapping/RKObjectManager.m b/Code/ObjectMapping/RKObjectManager.m index d1e392e0..e7eea561 100644 --- a/Code/ObjectMapping/RKObjectManager.m +++ b/Code/ObjectMapping/RKObjectManager.m @@ -66,6 +66,11 @@ static RKObjectManager* sharedManager = nil; selector:@selector(reachabilityChanged:) name:RKReachabilityDidChangeNotification object:_client.reachabilityObserver]; + + // Set shared manager if nil + if (nil == sharedManager) { + [RKObjectManager setSharedManager:self]; + } } return self; @@ -81,15 +86,12 @@ static RKObjectManager* sharedManager = nil; sharedManager = manager; } -+ (RKObjectManager*)objectManagerWithBaseURLString:(NSString *)baseURLString { - return [self objectManagerWithBaseURL:[RKURL URLWithString:baseURLString]]; ++ (RKObjectManager*)managerWithBaseURLString:(NSString *)baseURLString { + return [self managerWithBaseURL:[RKURL URLWithString:baseURLString]]; } -+ (RKObjectManager*)objectManagerWithBaseURL:(RKURL *)baseURL { - RKObjectManager* manager = [[[self alloc] initWithBaseURL:baseURL] autorelease]; - if (nil == sharedManager) { - [RKObjectManager setSharedManager:manager]; - } ++ (RKObjectManager*)managerWithBaseURL:(NSURL *)baseURL { + RKObjectManager* manager = [[[self alloc] initWithBaseURL:baseURL] autorelease]; return manager; } @@ -402,4 +404,14 @@ static RKObjectManager* sharedManager = nil; [self configureRequest:objectLoader]; } +#pragma mark - Deprecations + ++ (RKObjectManager*)objectManagerWithBaseURLString:(NSString *)baseURLString { + return [self managerWithBaseURLString:baseURLString]; +} + ++ (RKObjectManager*)objectManagerWithBaseURL:(NSURL *)baseURL { + return [self managerWithBaseURL:baseURL]; +} + @end diff --git a/Code/ObjectMapping/RKObjectMapper.m b/Code/ObjectMapping/RKObjectMapper.m index f1cb9887..e1af6e33 100644 --- a/Code/ObjectMapping/RKObjectMapper.m +++ b/Code/ObjectMapping/RKObjectMapper.m @@ -21,6 +21,7 @@ #import "RKObjectMapper.h" #import "RKObjectMapperError.h" #import "RKObjectMapper_Private.h" +#import "RKObjectMappingProvider+Contexts.h" // Set Logging Component #undef RKLogComponent diff --git a/Code/ObjectMapping/RKObjectMappingProvider+Contexts.h b/Code/ObjectMapping/RKObjectMappingProvider+Contexts.h new file mode 100644 index 00000000..85913a8e --- /dev/null +++ b/Code/ObjectMapping/RKObjectMappingProvider+Contexts.h @@ -0,0 +1,48 @@ +// +// RKObjectMappingProvider.m +// RestKit +// +// Created by Blake Watters on 1/17/12. +// Copyright 2011 RestKit +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +#import "RKObjectMappingProvider.h" + +// Contexts provide primitives for managing collections of object mappings namespaced +// within a single mapping provider. This enables easy reuse and extension via categories. +@interface RKObjectMappingProvider (Contexts) + +- (void)initializeContext:(RKObjectMappingProviderContext)context withValue:(id)value; +- (id)valueForContext:(RKObjectMappingProviderContext)context; +- (void)setValue:(id)value forContext:(RKObjectMappingProviderContext)context; + +- (id)mappingForContext:(RKObjectMappingProviderContext)context; +/** + Stores a single object mapping for a given context. Useful when a component needs to enable + configuration via one (and only one) object mapping. + */ +- (void)setMapping:(id)mapping context:(RKObjectMappingProviderContext)context; +- (NSArray *)mappingsForContext:(RKObjectMappingProviderContext)context; +- (void)addMapping:(id)mapping context:(RKObjectMappingProviderContext)context; +- (void)removeMapping:(id)mapping context:(RKObjectMappingProviderContext)context; +- (id)mappingForKeyPath:(NSString *)keyPath context:(RKObjectMappingProviderContext)context; +- (void)setMapping:(id)mapping forKeyPath:(NSString *)keyPath context:(RKObjectMappingProviderContext)context; +- (void)removeMappingForKeyPath:(NSString *)keyPath context:(RKObjectMappingProviderContext)context; + +- (void)setMapping:(id)mapping forPattern:(NSString *)pattern atIndex:(NSUInteger)index context:(RKObjectMappingProviderContext)context; +- (void)setMapping:(id)mapping forPattern:(NSString *)pattern context:(RKObjectMappingProviderContext)context; +- (id)mappingForPatternMatchingString:(NSString *)string context:(RKObjectMappingProviderContext)context; + +@end diff --git a/Code/ObjectMapping/RKObjectMappingProvider.h b/Code/ObjectMapping/RKObjectMappingProvider.h index 6e10e273..5211b8f2 100644 --- a/Code/ObjectMapping/RKObjectMappingProvider.h +++ b/Code/ObjectMapping/RKObjectMappingProvider.h @@ -22,6 +22,7 @@ #import "RKDynamicObjectMapping.h" // Internal framework contexts +// see RKObjectMappingProvider+Contexts typedef enum { RKObjectMappingProviderContextObjectsByKeyPath = 1000, RKObjectMappingProviderContextObjectsByType, @@ -266,31 +267,6 @@ typedef enum { @end -@interface RKObjectMappingProvider (Contexts) - -- (void)initializeContext:(RKObjectMappingProviderContext)context withValue:(id)value; -- (id)valueForContext:(RKObjectMappingProviderContext)context; -- (void)setValue:(id)value forContext:(RKObjectMappingProviderContext)context; - -- (id)mappingForContext:(RKObjectMappingProviderContext)context; -/** - Stores a single object mapping for a given context. Useful when a component needs to enable - configuration via one (and only one) object mapping. - */ -- (void)setMapping:(id)mapping context:(RKObjectMappingProviderContext)context; -- (NSArray *)mappingsForContext:(RKObjectMappingProviderContext)context; -- (void)addMapping:(id)mapping context:(RKObjectMappingProviderContext)context; -- (void)removeMapping:(id)mapping context:(RKObjectMappingProviderContext)context; -- (id)mappingForKeyPath:(NSString *)keyPath context:(RKObjectMappingProviderContext)context; -- (void)setMapping:(id)mapping forKeyPath:(NSString *)keyPath context:(RKObjectMappingProviderContext)context; -- (void)removeMappingForKeyPath:(NSString *)keyPath context:(RKObjectMappingProviderContext)context; - -- (void)setMapping:(id)mapping forPattern:(NSString *)pattern atIndex:(NSUInteger)index context:(RKObjectMappingProviderContext)context; -- (void)setMapping:(id)mapping forPattern:(NSString *)pattern context:(RKObjectMappingProviderContext)context; -- (id)mappingForPatternMatchingString:(NSString *)string context:(RKObjectMappingProviderContext)context; - -@end - // Method signatures being phased out @interface RKObjectMappingProvider (CompatibilityAliases) + (RKObjectMappingProvider *)objectMappingProvider; diff --git a/Code/ObjectMapping/RKObjectMappingProvider.m b/Code/ObjectMapping/RKObjectMappingProvider.m index 26b4ed64..2abf01d6 100644 --- a/Code/ObjectMapping/RKObjectMappingProvider.m +++ b/Code/ObjectMapping/RKObjectMappingProvider.m @@ -19,6 +19,7 @@ // #import "RKObjectMappingProvider.h" +#import "RKObjectMappingProvider+Contexts.h" #import "RKOrderedDictionary.h" #import "RKPathMatcher.h" diff --git a/Code/ObjectMapping/RKObjectPaginator.m b/Code/ObjectMapping/RKObjectPaginator.m index 88b292a0..65b8bbc4 100644 --- a/Code/ObjectMapping/RKObjectPaginator.m +++ b/Code/ObjectMapping/RKObjectPaginator.m @@ -163,7 +163,7 @@ static NSUInteger RKObjectPaginatorDefaultPerPage = 25; } else if (self.perPage && [self hasObjectCount]) { float objectCountFloat = self.objectCount; pageCount = ceilf(objectCountFloat / self.perPage); - RKLogInfo(@"Paginator objectCount: %d pageCount: %d", self.objectCount, self.pageCount); + RKLogInfo(@"Paginator objectCount: %ld pageCount: %ld", (long) self.objectCount, (long) self.pageCount); } else { NSAssert(NO, @"Paginator perPage set is 0."); RKLogError(@"Paginator perPage set is 0."); diff --git a/Examples/RKCatalog/App/RKCatalog.h b/Examples/RKCatalog/App/RKCatalog.h index 96ff1e64..d4710509 100644 --- a/Examples/RKCatalog/App/RKCatalog.h +++ b/Examples/RKCatalog/App/RKCatalog.h @@ -11,4 +11,4 @@ #import // Import the base URL defined in the app delegate -extern NSString* gRKCatalogBaseURL; +extern NSURL* gRKCatalogBaseURL; diff --git a/Examples/RKCatalog/App/RKCatalogAppDelegate.h b/Examples/RKCatalog/App/RKCatalogAppDelegate.h index 77e0915e..211e4422 100644 --- a/Examples/RKCatalog/App/RKCatalogAppDelegate.h +++ b/Examples/RKCatalog/App/RKCatalogAppDelegate.h @@ -3,7 +3,7 @@ // RKCatalog // // Created by Blake Watters on 4/21/11. -// Copyright 2011 Two Toasters. All rights reserved. +// Copyright 2011 RestKit. All rights reserved. // #import diff --git a/Examples/RKCatalog/App/RKCatalogAppDelegate.m b/Examples/RKCatalog/App/RKCatalogAppDelegate.m index 6e2ef2b9..619838a1 100644 --- a/Examples/RKCatalog/App/RKCatalogAppDelegate.m +++ b/Examples/RKCatalog/App/RKCatalogAppDelegate.m @@ -9,12 +9,12 @@ #import "RKCatalogAppDelegate.h" #import "RootViewController.h" -NSString* gRKCatalogBaseURL = nil; +NSURL *gRKCatalogBaseURL = nil; @implementation RKCatalogAppDelegate -@synthesize window=_window; -@synthesize navigationController=_navigationController; +@synthesize window; +@synthesize navigationController; - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { // Override point for customization after application launch. @@ -23,15 +23,14 @@ NSString* gRKCatalogBaseURL = nil; [self.window makeKeyAndVisible]; - // gRKCatalogBaseURL = [@"http://localhost:4567" retain]; - gRKCatalogBaseURL = [@"http://rkcatalog.heroku.com" retain]; + gRKCatalogBaseURL = [[NSURL alloc] initWithString:@"http://rkcatalog.heroku.com"]; return YES; } - (void)dealloc { - [_window release]; - [_navigationController release]; + [window release]; + [navigationController release]; [super dealloc]; } diff --git a/Examples/RKCatalog/Examples/RKAuthenticationExample/RKAuthenticationExample.h b/Examples/RKCatalog/Examples/RKAuthenticationExample/RKAuthenticationExample.h index 86114476..81899e60 100644 --- a/Examples/RKCatalog/Examples/RKAuthenticationExample/RKAuthenticationExample.h +++ b/Examples/RKCatalog/Examples/RKAuthenticationExample/RKAuthenticationExample.h @@ -11,6 +11,7 @@ @interface RKAuthenticationExample : UIViewController +@property (nonatomic, retain) RKRequest *authenticatedRequest; @property (nonatomic, retain) IBOutlet UITextField *URLTextField; @property (nonatomic, retain) IBOutlet UITextField *usernameTextField; @property (nonatomic, retain) IBOutlet UITextField *passwordTextField; diff --git a/Examples/RKCatalog/Examples/RKAuthenticationExample/RKAuthenticationExample.m b/Examples/RKCatalog/Examples/RKAuthenticationExample/RKAuthenticationExample.m index ff49a3f9..abf1e851 100644 --- a/Examples/RKCatalog/Examples/RKAuthenticationExample/RKAuthenticationExample.m +++ b/Examples/RKCatalog/Examples/RKAuthenticationExample/RKAuthenticationExample.m @@ -10,6 +10,7 @@ @implementation RKAuthenticationExample +@synthesize authenticatedRequest; @synthesize URLTextField; @synthesize usernameTextField; @synthesize passwordTextField; @@ -25,6 +26,14 @@ return self; } +- (void)dealloc { + [authenticatedRequest cancel]; + [authenticatedRequest release]; + authenticatedRequest = nil; + + [super dealloc]; +} + /** We are constructing our own RKRequest here rather than working with the client. It is important to remember that RKClient is really just a factory object for instances @@ -32,20 +41,23 @@ */ - (void)sendRequest { NSURL *URL = [NSURL URLWithString:[URLTextField text]]; - RKRequest *request = [RKRequest requestWithURL:URL delegate:self]; - request.queue = [RKClient sharedClient].requestQueue; - request.authenticationType = RKRequestAuthenticationTypeHTTP; - request.username = [usernameTextField text]; - request.password = [passwordTextField text]; - [request send]; + RKRequest *newRequest = [RKRequest requestWithURL:URL]; + newRequest.delegate = self; + newRequest.authenticationType = RKRequestAuthenticationTypeHTTP; + newRequest.username = [usernameTextField text]; + newRequest.password = [passwordTextField text]; + + self.authenticatedRequest = newRequest; } - (void)request:(RKRequest *)request didFailLoadWithError:(NSError *)error { RKLogError(@"Load of RKRequest %@ failed with error: %@", request, error); + [request release]; } - (void)request:(RKRequest *)request didLoadResponse:(RKResponse *)response { RKLogCritical(@"Loading of RKRequest %@ completed with status code %d. Response body: %@", request, response.statusCode, [response bodyAsString]); + [request release]; } #pragma mark - UIPickerViewDataSource diff --git a/Examples/RKCatalog/Examples/RKBackgroundRequestExample/RKBackgroundRequestExample.m b/Examples/RKCatalog/Examples/RKBackgroundRequestExample/RKBackgroundRequestExample.m index b8739193..37c3f8f2 100644 --- a/Examples/RKCatalog/Examples/RKBackgroundRequestExample/RKBackgroundRequestExample.m +++ b/Examples/RKCatalog/Examples/RKBackgroundRequestExample/RKBackgroundRequestExample.m @@ -32,7 +32,8 @@ } - (IBAction)sendRequest { - RKRequest* request = [[RKClient sharedClient] requestWithResourcePath:@"/RKBackgroundRequestExample" delegate:self]; + RKRequest* request = [[RKClient sharedClient] requestWithResourcePath:@"/RKBackgroundRequestExample"]; + request.delegate = self; request.backgroundPolicy = _segmentedControl.selectedSegmentIndex; [request send]; _sendButton.enabled = NO; diff --git a/Examples/RKCatalog/Examples/RKCoreDataExample/RKCoreDataExample.m b/Examples/RKCatalog/Examples/RKCoreDataExample/RKCoreDataExample.m index a632c17a..08660fd9 100644 --- a/Examples/RKCatalog/Examples/RKCoreDataExample/RKCoreDataExample.m +++ b/Examples/RKCatalog/Examples/RKCoreDataExample/RKCoreDataExample.m @@ -34,7 +34,7 @@ - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; if (self) { - RKObjectManager* manager = [RKObjectManager objectManagerWithBaseURL:@"http://restkit.org"]; + RKObjectManager* manager = [RKObjectManager managerWithBaseURLString:@"http://restkit.org"]; manager.objectStore = [RKManagedObjectStore objectStoreWithStoreFilename:@"RKCoreDataExample.sqlite"]; [RKObjectManager setSharedManager:manager]; diff --git a/Examples/RKCatalog/Examples/RKKeyValueMappingExample/RKKeyValueMappingExample.m b/Examples/RKCatalog/Examples/RKKeyValueMappingExample/RKKeyValueMappingExample.m index db485a77..404d5b0f 100644 --- a/Examples/RKCatalog/Examples/RKKeyValueMappingExample/RKKeyValueMappingExample.m +++ b/Examples/RKCatalog/Examples/RKKeyValueMappingExample/RKKeyValueMappingExample.m @@ -51,7 +51,7 @@ - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; if (self) { - [RKObjectManager objectManagerWithBaseURL:gRKCatalogBaseURL]; + [RKObjectManager managerWithBaseURL:gRKCatalogBaseURL]; } return self; diff --git a/Examples/RKCatalog/Examples/RKRelationshipMappingExample/RKRelationshipMappingExample.m b/Examples/RKCatalog/Examples/RKRelationshipMappingExample/RKRelationshipMappingExample.m index b390cc3e..f9ecbb28 100644 --- a/Examples/RKCatalog/Examples/RKRelationshipMappingExample/RKRelationshipMappingExample.m +++ b/Examples/RKCatalog/Examples/RKRelationshipMappingExample/RKRelationshipMappingExample.m @@ -18,7 +18,7 @@ - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; if (self) { - RKObjectManager* objectManager = [RKObjectManager objectManagerWithBaseURL:gRKCatalogBaseURL]; + RKObjectManager* objectManager = [RKObjectManager managerWithBaseURL:gRKCatalogBaseURL]; objectManager.objectStore = [RKManagedObjectStore objectStoreWithStoreFilename:@"RKRelationshipMappingExample.sqlite"]; RKManagedObjectMapping* taskMapping = [RKManagedObjectMapping mappingForClass:[Task class]]; diff --git a/Examples/RKCatalog/Examples/RKRequestQueueExample/RKRequestQueueExample.h b/Examples/RKCatalog/Examples/RKRequestQueueExample/RKRequestQueueExample.h index 49202610..d6b592f2 100644 --- a/Examples/RKCatalog/Examples/RKRequestQueueExample/RKRequestQueueExample.h +++ b/Examples/RKCatalog/Examples/RKRequestQueueExample/RKRequestQueueExample.h @@ -3,18 +3,15 @@ // RKCatalog // // Created by Blake Watters on 4/21/11. -// Copyright 2011 Two Toasters. All rights reserved. +// Copyright 2011 RestKit. All rights reserved. // #import "RKCatalog.h" -@interface RKRequestQueueExample : UIViewController { - UILabel* _statusLabel; - RKRequestQueue* _queue; -} +@interface RKRequestQueueExample : UIViewController -@property (nonatomic, retain) RKRequestQueue* queue; -@property (nonatomic, retain) IBOutlet UILabel* statusLabel; +@property (nonatomic, retain) RKRequestQueue *requestQueue; +@property (nonatomic, retain) IBOutlet UILabel *statusLabel; - (IBAction)sendRequest; - (IBAction)queueRequests; diff --git a/Examples/RKCatalog/Examples/RKRequestQueueExample/RKRequestQueueExample.m b/Examples/RKCatalog/Examples/RKRequestQueueExample/RKRequestQueueExample.m index 51208c9a..35fb9b2f 100644 --- a/Examples/RKCatalog/Examples/RKRequestQueueExample/RKRequestQueueExample.m +++ b/Examples/RKCatalog/Examples/RKRequestQueueExample/RKRequestQueueExample.m @@ -3,7 +3,7 @@ // RKCatalog // // Created by Blake Watters on 4/21/11. -// Copyright 2011 Two Toasters. All rights reserved. +// Copyright 2011 RestKit. All rights reserved. // #import @@ -11,8 +11,8 @@ @implementation RKRequestQueueExample -@synthesize queue = _queue; -@synthesize statusLabel = _statusLabel; +@synthesize requestQueue; +@synthesize statusLabel; - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; @@ -31,8 +31,9 @@ // We have been dismissed -- clean up any open requests - (void)dealloc { [[RKClient sharedClient].requestQueue cancelRequestsWithDelegate:self]; - [_queue cancelAllRequests]; - [_queue release]; + [requestQueue cancelAllRequests]; + [requestQueue release]; + requestQueue = nil; [super dealloc]; } @@ -51,36 +52,44 @@ } - (IBAction)queueRequests { - RKRequestQueue* queue = [RKRequestQueue new]; + RKRequestQueue *queue = [RKRequestQueue requestQueue]; queue.delegate = self; queue.concurrentRequestsLimit = 1; queue.showsNetworkActivityIndicatorWhenBusy = YES; // Queue up 4 requests - [queue addRequest:[[RKClient sharedClient] requestWithResourcePath:@"/RKRequestQueueExample" delegate:self]]; - [queue addRequest:[[RKClient sharedClient] requestWithResourcePath:@"/RKRequestQueueExample" delegate:self]]; - [queue addRequest:[[RKClient sharedClient] requestWithResourcePath:@"/RKRequestQueueExample" delegate:self]]; - [queue addRequest:[[RKClient sharedClient] requestWithResourcePath:@"/RKRequestQueueExample" delegate:self]]; + RKRequest *request = [[RKClient sharedClient] requestWithResourcePath:@"/RKRequestQueueExample"]; + request.delegate = self; + [queue addRequest:request]; + + request = [[RKClient sharedClient] requestWithResourcePath:@"/RKRequestQueueExample"]; + request.delegate = self; + [queue addRequest:request]; + + request = [[RKClient sharedClient] requestWithResourcePath:@"/RKRequestQueueExample"]; + request.delegate = self; + [queue addRequest:request]; + + request = [[RKClient sharedClient] requestWithResourcePath:@"/RKRequestQueueExample"]; + request.delegate = self; + [queue addRequest:request]; // Start processing! [queue start]; - - // Manage memory for our ad-hoc queue - self.queue = queue; - [queue release]; + self.requestQueue = queue; } - (void)requestQueue:(RKRequestQueue *)queue didSendRequest:(RKRequest *)request { - _statusLabel.text = [NSString stringWithFormat:@"RKRequestQueue %@ is current loading %d of %d requests", + statusLabel.text = [NSString stringWithFormat:@"RKRequestQueue %@ is current loading %d of %d requests", queue, [queue loadingCount], [queue count]]; } - (void)requestQueueDidBeginLoading:(RKRequestQueue *)queue { - _statusLabel.text = [NSString stringWithFormat:@"Queue %@ Began Loading...", queue]; + statusLabel.text = [NSString stringWithFormat:@"Queue %@ Began Loading...", queue]; } - (void)requestQueueDidFinishLoading:(RKRequestQueue *)queue { - _statusLabel.text = [NSString stringWithFormat:@"Queue %@ Finished Loading...", queue]; + statusLabel.text = [NSString stringWithFormat:@"Queue %@ Finished Loading...", queue]; } @end diff --git a/Examples/RKMacOSX/RKMacOSX.xcodeproj/project.pbxproj b/Examples/RKMacOSX/RKMacOSX.xcodeproj/project.pbxproj index 69c3668e..7b0373c2 100644 --- a/Examples/RKMacOSX/RKMacOSX.xcodeproj/project.pbxproj +++ b/Examples/RKMacOSX/RKMacOSX.xcodeproj/project.pbxproj @@ -7,106 +7,53 @@ objects = { /* Begin PBXBuildFile section */ + 250DF24F14C67F560001DEFA /* RestKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 250DF24B14C67E9A0001DEFA /* RestKit.framework */; }; 25D63919135184CE000879B1 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 25D63918135184CE000879B1 /* Cocoa.framework */; }; 25D63923135184CE000879B1 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 25D63921135184CE000879B1 /* InfoPlist.strings */; }; 25D63926135184CE000879B1 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 25D63925135184CE000879B1 /* main.m */; }; 25D63929135184CE000879B1 /* Credits.rtf in Resources */ = {isa = PBXBuildFile; fileRef = 25D63927135184CE000879B1 /* Credits.rtf */; }; 25D6392C135184CE000879B1 /* RKMacOSXAppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 25D6392B135184CE000879B1 /* RKMacOSXAppDelegate.m */; }; 25D6392F135184CF000879B1 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 25D6392D135184CF000879B1 /* MainMenu.xib */; }; - 25D6397813518514000879B1 /* libRestKitCoreData.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 25D6397213518514000879B1 /* libRestKitCoreData.a */; }; - 25D6397913518514000879B1 /* libRestKitJSONParserJSONKit.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 25D6397313518514000879B1 /* libRestKitJSONParserJSONKit.a */; }; - 25D6397A13518514000879B1 /* libRestKitNetwork.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 25D6397413518514000879B1 /* libRestKitNetwork.a */; }; - 25D6397B13518514000879B1 /* libRestKitObjectMapping.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 25D6397513518514000879B1 /* libRestKitObjectMapping.a */; }; - 25D6397C13518514000879B1 /* libRestKitSupport.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 25D6397613518514000879B1 /* libRestKitSupport.a */; }; 25D6397F13518574000879B1 /* CoreData.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 25D6397E13518574000879B1 /* CoreData.framework */; }; 25D639811351858A000879B1 /* AppKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 25D639801351858A000879B1 /* AppKit.framework */; }; 25D63983135185B6000879B1 /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 25D63982135185B6000879B1 /* SystemConfiguration.framework */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ - 25D63957135184F1000879B1 /* PBXContainerItemProxy */ = { + 250DF24614C67E9A0001DEFA /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 25D63938135184F0000879B1 /* RestKit.xcodeproj */; proxyType = 2; - remoteGlobalIDString = 253A07FC1255161B00976E89; - remoteInfo = RestKitNetwork; + remoteGlobalIDString = 25160D1614564E810060A5C5; + remoteInfo = RestKit; }; - 25D63959135184F1000879B1 /* PBXContainerItemProxy */ = { + 250DF24814C67E9A0001DEFA /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 25D63938135184F0000879B1 /* RestKit.xcodeproj */; proxyType = 2; - remoteGlobalIDString = 253A08031255162C00976E89; - remoteInfo = RestKitObjectMapping; + remoteGlobalIDString = 25160D2614564E820060A5C5; + remoteInfo = RestKitTests; }; - 25D6395B135184F1000879B1 /* PBXContainerItemProxy */ = { + 250DF24A14C67E9A0001DEFA /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 25D63938135184F0000879B1 /* RestKit.xcodeproj */; proxyType = 2; - remoteGlobalIDString = 253A080C12551D3000976E89; - remoteInfo = RestKitSupport; + remoteGlobalIDString = 25160E62145651060060A5C5; + remoteInfo = RestKitFramework; }; - 25D6395D135184F1000879B1 /* PBXContainerItemProxy */ = { + 250DF24C14C67E9A0001DEFA /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 25D63938135184F0000879B1 /* RestKit.xcodeproj */; proxyType = 2; - remoteGlobalIDString = 2590E64F125231F600531FA8; - remoteInfo = "RestKitJSONParser+YAJL"; + remoteGlobalIDString = 25160E78145651060060A5C5; + remoteInfo = RestKitFrameworkTests; }; - 25D6395F135184F1000879B1 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 25D63938135184F0000879B1 /* RestKit.xcodeproj */; - proxyType = 2; - remoteGlobalIDString = 2590E66B1252353700531FA8; - remoteInfo = "RestKitJSONParser+SBJSON"; - }; - 25D63961135184F1000879B1 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 25D63938135184F0000879B1 /* RestKit.xcodeproj */; - proxyType = 2; - remoteGlobalIDString = 73057FD11331AD2E001908EE; - remoteInfo = "RestKitJSONParser+JSONKit"; - }; - 25D63963135184F1000879B1 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 25D63938135184F0000879B1 /* RestKit.xcodeproj */; - proxyType = 2; - remoteGlobalIDString = 25BD43BD1340315800DBACDD; - remoteInfo = "RestKitXMLParser+Libxml"; - }; - 25D63965135184F1000879B1 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 25D63938135184F0000879B1 /* RestKit.xcodeproj */; - proxyType = 2; - remoteGlobalIDString = 253A081412551D5300976E89; - remoteInfo = RestKitCoreData; - }; - 25D63967135184F1000879B1 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 25D63938135184F0000879B1 /* RestKit.xcodeproj */; - proxyType = 2; - remoteGlobalIDString = 2523360511E79F090048F9B4; - remoteInfo = RestKitThree20; - }; - 25D63969135184F1000879B1 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 25D63938135184F0000879B1 /* RestKit.xcodeproj */; - proxyType = 2; - remoteGlobalIDString = 3F6C39A510FE5C95008F47C5; - remoteInfo = UISpec; - }; - 25D6397013518504000879B1 /* PBXContainerItemProxy */ = { + 250DF25014C67F630001DEFA /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 25D63938135184F0000879B1 /* RestKit.xcodeproj */; proxyType = 1; - remoteGlobalIDString = 255B7588133BABBF00ED76AD; - remoteInfo = RestKit; - }; - 25FB6D9F13E4848200F48969 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 25D63938135184F0000879B1 /* RestKit.xcodeproj */; - proxyType = 2; - remoteGlobalIDString = 20808DBD13DE8CDC000A156A; - remoteInfo = "RestKitJSONParser+NXJSON"; + remoteGlobalIDString = 25160E61145651060060A5C5; + remoteInfo = RestKitFramework; }; /* End PBXContainerItemProxy section */ @@ -141,14 +88,10 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + 250DF24F14C67F560001DEFA /* RestKit.framework in Frameworks */, 25D63983135185B6000879B1 /* SystemConfiguration.framework in Frameworks */, 25D639811351858A000879B1 /* AppKit.framework in Frameworks */, 25D6397F13518574000879B1 /* CoreData.framework in Frameworks */, - 25D6397813518514000879B1 /* libRestKitCoreData.a in Frameworks */, - 25D6397913518514000879B1 /* libRestKitJSONParserJSONKit.a in Frameworks */, - 25D6397A13518514000879B1 /* libRestKitNetwork.a in Frameworks */, - 25D6397B13518514000879B1 /* libRestKitObjectMapping.a in Frameworks */, - 25D6397C13518514000879B1 /* libRestKitSupport.a in Frameworks */, 25D63919135184CE000879B1 /* Cocoa.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; @@ -222,17 +165,10 @@ 25D63939135184F0000879B1 /* Products */ = { isa = PBXGroup; children = ( - 25D63958135184F1000879B1 /* libRestKitNetwork.a */, - 25D6395A135184F1000879B1 /* libRestKitObjectMapping.a */, - 25D6395C135184F1000879B1 /* libRestKitSupport.a */, - 25FB6DA013E4848200F48969 /* libRestKitJSONParserNXJSON.a */, - 25D6395E135184F1000879B1 /* libRestKitJSONParserYAJL.a */, - 25D63960135184F1000879B1 /* libRestKitJSONParserSBJSON.a */, - 25D63962135184F1000879B1 /* libRestKitJSONParserJSONKit.a */, - 25D63964135184F1000879B1 /* libRestKitXMLParserLibxml.a */, - 25D63966135184F1000879B1 /* libRestKitCoreData.a */, - 25D63968135184F1000879B1 /* libRestKitThree20.a */, - 25D6396A135184F1000879B1 /* RestKitSpecs.app */, + 250DF24714C67E9A0001DEFA /* libRestKit.a */, + 250DF24914C67E9A0001DEFA /* RestKitTests.octest */, + 250DF24B14C67E9A0001DEFA /* RestKit.framework */, + 250DF24D14C67E9A0001DEFA /* RestKitFrameworkTests.octest */, ); name = Products; sourceTree = ""; @@ -265,7 +201,7 @@ buildRules = ( ); dependencies = ( - 25D6397113518504000879B1 /* PBXTargetDependency */, + 250DF25114C67F630001DEFA /* PBXTargetDependency */, ); name = RKMacOSX; productName = RKMacOSX; @@ -304,81 +240,32 @@ /* End PBXProject section */ /* Begin PBXReferenceProxy section */ - 25D63958135184F1000879B1 /* libRestKitNetwork.a */ = { + 250DF24714C67E9A0001DEFA /* libRestKit.a */ = { isa = PBXReferenceProxy; fileType = archive.ar; - path = libRestKitNetwork.a; - remoteRef = 25D63957135184F1000879B1 /* PBXContainerItemProxy */; + path = libRestKit.a; + remoteRef = 250DF24614C67E9A0001DEFA /* PBXContainerItemProxy */; sourceTree = BUILT_PRODUCTS_DIR; }; - 25D6395A135184F1000879B1 /* libRestKitObjectMapping.a */ = { + 250DF24914C67E9A0001DEFA /* RestKitTests.octest */ = { isa = PBXReferenceProxy; - fileType = archive.ar; - path = libRestKitObjectMapping.a; - remoteRef = 25D63959135184F1000879B1 /* PBXContainerItemProxy */; + fileType = wrapper.cfbundle; + path = RestKitTests.octest; + remoteRef = 250DF24814C67E9A0001DEFA /* PBXContainerItemProxy */; sourceTree = BUILT_PRODUCTS_DIR; }; - 25D6395C135184F1000879B1 /* libRestKitSupport.a */ = { + 250DF24B14C67E9A0001DEFA /* RestKit.framework */ = { isa = PBXReferenceProxy; - fileType = archive.ar; - path = libRestKitSupport.a; - remoteRef = 25D6395B135184F1000879B1 /* PBXContainerItemProxy */; + fileType = wrapper.framework; + path = RestKit.framework; + remoteRef = 250DF24A14C67E9A0001DEFA /* PBXContainerItemProxy */; sourceTree = BUILT_PRODUCTS_DIR; }; - 25D6395E135184F1000879B1 /* libRestKitJSONParserYAJL.a */ = { + 250DF24D14C67E9A0001DEFA /* RestKitFrameworkTests.octest */ = { isa = PBXReferenceProxy; - fileType = archive.ar; - path = libRestKitJSONParserYAJL.a; - remoteRef = 25D6395D135184F1000879B1 /* PBXContainerItemProxy */; - sourceTree = BUILT_PRODUCTS_DIR; - }; - 25D63960135184F1000879B1 /* libRestKitJSONParserSBJSON.a */ = { - isa = PBXReferenceProxy; - fileType = archive.ar; - path = libRestKitJSONParserSBJSON.a; - remoteRef = 25D6395F135184F1000879B1 /* PBXContainerItemProxy */; - sourceTree = BUILT_PRODUCTS_DIR; - }; - 25D63962135184F1000879B1 /* libRestKitJSONParserJSONKit.a */ = { - isa = PBXReferenceProxy; - fileType = archive.ar; - path = libRestKitJSONParserJSONKit.a; - remoteRef = 25D63961135184F1000879B1 /* PBXContainerItemProxy */; - sourceTree = BUILT_PRODUCTS_DIR; - }; - 25D63964135184F1000879B1 /* libRestKitXMLParserLibxml.a */ = { - isa = PBXReferenceProxy; - fileType = archive.ar; - path = libRestKitXMLParserLibxml.a; - remoteRef = 25D63963135184F1000879B1 /* PBXContainerItemProxy */; - sourceTree = BUILT_PRODUCTS_DIR; - }; - 25D63966135184F1000879B1 /* libRestKitCoreData.a */ = { - isa = PBXReferenceProxy; - fileType = archive.ar; - path = libRestKitCoreData.a; - remoteRef = 25D63965135184F1000879B1 /* PBXContainerItemProxy */; - sourceTree = BUILT_PRODUCTS_DIR; - }; - 25D63968135184F1000879B1 /* libRestKitThree20.a */ = { - isa = PBXReferenceProxy; - fileType = archive.ar; - path = libRestKitThree20.a; - remoteRef = 25D63967135184F1000879B1 /* PBXContainerItemProxy */; - sourceTree = BUILT_PRODUCTS_DIR; - }; - 25D6396A135184F1000879B1 /* RestKitSpecs.app */ = { - isa = PBXReferenceProxy; - fileType = wrapper.application; - path = RestKitSpecs.app; - remoteRef = 25D63969135184F1000879B1 /* PBXContainerItemProxy */; - sourceTree = BUILT_PRODUCTS_DIR; - }; - 25FB6DA013E4848200F48969 /* libRestKitJSONParserNXJSON.a */ = { - isa = PBXReferenceProxy; - fileType = archive.ar; - path = libRestKitJSONParserNXJSON.a; - remoteRef = 25FB6D9F13E4848200F48969 /* PBXContainerItemProxy */; + fileType = wrapper.cfbundle; + path = RestKitFrameworkTests.octest; + remoteRef = 250DF24C14C67E9A0001DEFA /* PBXContainerItemProxy */; sourceTree = BUILT_PRODUCTS_DIR; }; /* End PBXReferenceProxy section */ @@ -409,10 +296,10 @@ /* End PBXSourcesBuildPhase section */ /* Begin PBXTargetDependency section */ - 25D6397113518504000879B1 /* PBXTargetDependency */ = { + 250DF25114C67F630001DEFA /* PBXTargetDependency */ = { isa = PBXTargetDependency; - name = RestKit; - targetProxy = 25D6397013518504000879B1 /* PBXContainerItemProxy */; + name = RestKitFramework; + targetProxy = 250DF25014C67F630001DEFA /* PBXContainerItemProxy */; }; /* End PBXTargetDependency section */ diff --git a/Examples/RKMacOSX/RKMacOSX/RKMacOSXAppDelegate.h b/Examples/RKMacOSX/RKMacOSX/RKMacOSXAppDelegate.h index f223d200..fd2e112e 100644 --- a/Examples/RKMacOSX/RKMacOSX/RKMacOSXAppDelegate.h +++ b/Examples/RKMacOSX/RKMacOSX/RKMacOSXAppDelegate.h @@ -3,17 +3,15 @@ // RKMacOSX // // Created by Blake Watters on 4/10/11. -// Copyright 2011 __MyCompanyName__. All rights reserved. +// Copyright 2011 RestKit. All rights reserved. // #import #import -@interface RKMacOSXAppDelegate : NSObject { -@private - NSWindow *window; -} +@interface RKMacOSXAppDelegate : NSObject +@property (nonatomic, retain) RKClient *client; @property (assign) IBOutlet NSWindow *window; @end diff --git a/Examples/RKMacOSX/RKMacOSX/RKMacOSXAppDelegate.m b/Examples/RKMacOSX/RKMacOSX/RKMacOSXAppDelegate.m index 111b68f6..a090b87e 100644 --- a/Examples/RKMacOSX/RKMacOSX/RKMacOSXAppDelegate.m +++ b/Examples/RKMacOSX/RKMacOSX/RKMacOSXAppDelegate.m @@ -3,20 +3,21 @@ // RKMacOSX // // Created by Blake Watters on 4/10/11. -// Copyright 2011 __MyCompanyName__. All rights reserved. +// Copyright 2011 RestKit. All rights reserved. // #import "RKMacOSXAppDelegate.h" @implementation RKMacOSXAppDelegate +@synthesize client; @synthesize window; - (void)applicationDidFinishLaunching:(NSNotification *)aNotification { // Initialize RestKit - RKClient* client = [RKClient clientWithBaseURL:@"http://twitter.com"]; - [client get:@"/status/user_timeline/twotoasters.json" delegate:self]; + self.client = [RKClient clientWithBaseURL:[RKURL URLWithBaseURLString:@"http://twitter.com"]]; + [self.client get:@"/status/user_timeline/RestKit.json" delegate:self]; } - (void)request:(RKRequest*)request didLoadResponse:(RKResponse *)response { diff --git a/Examples/RKTwitter/Classes/RKTwitterAppDelegate.m b/Examples/RKTwitter/Classes/RKTwitterAppDelegate.m index 4d2249b7..2a16d149 100644 --- a/Examples/RKTwitter/Classes/RKTwitterAppDelegate.m +++ b/Examples/RKTwitter/Classes/RKTwitterAppDelegate.m @@ -20,7 +20,7 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { RKLogConfigureByName("RestKit/Network*", RKLogLevelTrace); // Initialize RestKit - RKObjectManager* objectManager = [RKObjectManager objectManagerWithBaseURL:@"http://twitter.com"]; + RKObjectManager* objectManager = [RKObjectManager managerWithBaseURLString:@"http://twitter.com"]; // Enable automatic network activity indicator management objectManager.client.requestQueue.showsNetworkActivityIndicatorWhenBusy = YES; @@ -45,9 +45,8 @@ // Wed Sep 29 15:31:08 +0000 2010 [RKObjectMapping addDefaultDateFormatterForString:@"E MMM d HH:mm:ss Z y" inTimeZone:nil]; - // Register our mappings with the provider - [objectManager.mappingProvider setMapping:userMapping forKeyPath:@"user"]; - [objectManager.mappingProvider setMapping:statusMapping forKeyPath:@"status"]; + // Register our mappings with the provider using a resource path pattern + [objectManager.mappingProvider setObjectMapping:statusMapping forResourcePathPattern:@"/status/user_timeline/:username"]; // Uncomment this to use XML, comment it to use JSON // objectManager.acceptMIMEType = RKMIMETypeXML; diff --git a/Examples/RKTwitter/Classes/RKTwitterViewController.m b/Examples/RKTwitter/Classes/RKTwitterViewController.m index 35c6e208..965adc73 100644 --- a/Examples/RKTwitter/Classes/RKTwitterViewController.m +++ b/Examples/RKTwitter/Classes/RKTwitterViewController.m @@ -18,14 +18,8 @@ - (void)loadTimeline { // Load the object model via RestKit RKObjectManager* objectManager = [RKObjectManager sharedManager]; - objectManager.client.baseURL = @"http://www.twitter.com"; - [objectManager loadObjectsAtResourcePath:@"/status/user_timeline/RestKit" delegate:self block:^(RKObjectLoader* loader) { - // Twitter returns statuses as a naked array in JSON, so we instruct the loader - // to user the appropriate object mapping - if ([objectManager.acceptMIMEType isEqualToString:RKMIMETypeJSON]) { - loader.objectMapping = [objectManager.mappingProvider objectMappingForClass:[RKTStatus class]]; - } - }]; + objectManager.client.baseURL = [RKURL URLWithString:@"http://www.twitter.com"]; + [objectManager loadObjectsAtResourcePath:@"/status/user_timeline/RestKit" delegate:self]; } - (void)loadView { diff --git a/Examples/RKTwitterCoreData/Classes/RKTwitterAppDelegate.m b/Examples/RKTwitterCoreData/Classes/RKTwitterAppDelegate.m index ac3dea1a..bb04c079 100644 --- a/Examples/RKTwitterCoreData/Classes/RKTwitterAppDelegate.m +++ b/Examples/RKTwitterCoreData/Classes/RKTwitterAppDelegate.m @@ -19,7 +19,7 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { // Initialize RestKit - RKObjectManager* objectManager = [RKObjectManager objectManagerWithBaseURL:@"http://twitter.com"]; + RKObjectManager* objectManager = [RKObjectManager managerWithBaseURLString:@"http://twitter.com"]; // Enable automatic network activity indicator management objectManager.client.requestQueue.showsNetworkActivityIndicatorWhenBusy = YES; @@ -68,8 +68,7 @@ [RKObjectMapping addDefaultDateFormatterForString:@"E MMM d HH:mm:ss Z y" inTimeZone:nil]; // Register our mappings with the provider - [objectManager.mappingProvider setMapping:userMapping forKeyPath:@"user"]; - [objectManager.mappingProvider setMapping:statusMapping forKeyPath:@"status"]; + [objectManager.mappingProvider setObjectMapping:statusMapping forResourcePathPattern:@"/status/user_timeline/:username"]; // Uncomment this to use XML, comment it to use JSON // objectManager.acceptMIMEType = RKMIMETypeXML; diff --git a/Examples/RKTwitterCoreData/Classes/RKTwitterViewController.m b/Examples/RKTwitterCoreData/Classes/RKTwitterViewController.m index 794655f5..89684338 100644 --- a/Examples/RKTwitterCoreData/Classes/RKTwitterViewController.m +++ b/Examples/RKTwitterCoreData/Classes/RKTwitterViewController.m @@ -53,11 +53,7 @@ - (void)loadData { // Load the object model via RestKit RKObjectManager* objectManager = [RKObjectManager sharedManager]; - [objectManager loadObjectsAtResourcePath:@"/status/user_timeline/RestKit" delegate:self block:^(RKObjectLoader* loader) { - // Twitter returns statuses as a naked array in JSON, so we instruct the loader - // to user the appropriate object mapping - loader.objectMapping = [objectManager.mappingProvider objectMappingForClass:[RKTStatus class]]; - }]; + [objectManager loadObjectsAtResourcePath:@"/status/user_timeline/RestKit" delegate:self]; } - (void)reloadButtonWasPressed:(id)sender { diff --git a/Examples/RestKit CLI/RestKit CLI.xcodeproj/project.pbxproj b/Examples/RestKit CLI/RestKit CLI.xcodeproj/project.pbxproj index 959421cb..93a0516c 100644 --- a/Examples/RestKit CLI/RestKit CLI.xcodeproj/project.pbxproj +++ b/Examples/RestKit CLI/RestKit CLI.xcodeproj/project.pbxproj @@ -7,6 +7,7 @@ objects = { /* Begin PBXBuildFile section */ + 250DF27B14C684510001DEFA /* RestKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 25A3422B147D885B0009758D /* RestKit.framework */; }; 2516F0FC144A8577004631A1 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2516F0FB144A8577004631A1 /* Foundation.framework */; }; 2516F0FF144A8577004631A1 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 2516F0FE144A8577004631A1 /* main.m */; }; 2516F103144A8577004631A1 /* RestKit_CLI.1 in CopyFiles */ = {isa = PBXBuildFile; fileRef = 2516F102144A8577004631A1 /* RestKit_CLI.1 */; }; @@ -85,6 +86,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + 250DF27B14C684510001DEFA /* RestKit.framework in Frameworks */, 25A34230147D88630009758D /* Security.framework in Frameworks */, 2516F162144A8AED004631A1 /* CoreServices.framework in Frameworks */, 2516F160144A895E004631A1 /* libxml2.dylib in Frameworks */, diff --git a/RestKit.xcodeproj/project.pbxproj b/RestKit.xcodeproj/project.pbxproj index ffd181e4..85e54e99 100644 --- a/RestKit.xcodeproj/project.pbxproj +++ b/RestKit.xcodeproj/project.pbxproj @@ -14,6 +14,8 @@ 250DF22B14C5190E0001DEFA /* RKOrderedDictionary.h in Headers */ = {isa = PBXBuildFile; fileRef = 250DF22814C5190E0001DEFA /* RKOrderedDictionary.h */; settings = {ATTRIBUTES = (Public, ); }; }; 250DF22C14C5190E0001DEFA /* RKOrderedDictionary.m in Sources */ = {isa = PBXBuildFile; fileRef = 250DF22914C5190E0001DEFA /* RKOrderedDictionary.m */; }; 250DF22D14C5190E0001DEFA /* RKOrderedDictionary.m in Sources */ = {isa = PBXBuildFile; fileRef = 250DF22914C5190E0001DEFA /* RKOrderedDictionary.m */; }; + 250DF25F14C680F90001DEFA /* RKObjectMappingProvider+Contexts.h in Headers */ = {isa = PBXBuildFile; fileRef = 250DF25E14C680F90001DEFA /* RKObjectMappingProvider+Contexts.h */; }; + 250DF26014C680F90001DEFA /* RKObjectMappingProvider+Contexts.h in Headers */ = {isa = PBXBuildFile; fileRef = 250DF25E14C680F90001DEFA /* RKObjectMappingProvider+Contexts.h */; }; 2513504E14B8FE6B00A7E893 /* RKConfigurationDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = 2513504D14B8FE6B00A7E893 /* RKConfigurationDelegate.h */; settings = {ATTRIBUTES = (Public, ); }; }; 2513504F14B8FE6B00A7E893 /* RKConfigurationDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = 2513504D14B8FE6B00A7E893 /* RKConfigurationDelegate.h */; settings = {ATTRIBUTES = (Public, ); }; }; 25160D1A14564E810060A5C5 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 25160D1914564E810060A5C5 /* Foundation.framework */; }; @@ -566,6 +568,7 @@ 250CA67C147D8E800047D347 /* OCHamcrestIOS.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = OCHamcrestIOS.framework; sourceTree = ""; }; 250DF22814C5190E0001DEFA /* RKOrderedDictionary.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RKOrderedDictionary.h; sourceTree = ""; }; 250DF22914C5190E0001DEFA /* RKOrderedDictionary.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RKOrderedDictionary.m; sourceTree = ""; }; + 250DF25E14C680F90001DEFA /* RKObjectMappingProvider+Contexts.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "RKObjectMappingProvider+Contexts.h"; sourceTree = ""; }; 2513504D14B8FE6B00A7E893 /* RKConfigurationDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RKConfigurationDelegate.h; sourceTree = ""; }; 25160D1614564E810060A5C5 /* libRestKit.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libRestKit.a; sourceTree = BUILT_PRODUCTS_DIR; }; 25160D1914564E810060A5C5 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; @@ -1113,6 +1116,7 @@ 254A62B714AD544200939BEE /* RKObjectPaginator.h */, 254A62B814AD544200939BEE /* RKObjectPaginator.m */, 2513504D14B8FE6B00A7E893 /* RKConfigurationDelegate.h */, + 250DF25E14C680F90001DEFA /* RKObjectMappingProvider+Contexts.h */, ); path = ObjectMapping; sourceTree = ""; @@ -1687,6 +1691,7 @@ 25B408261491CDDC00F21111 /* RKDirectory.h in Headers */, 2513504E14B8FE6B00A7E893 /* RKConfigurationDelegate.h in Headers */, 250DF22A14C5190E0001DEFA /* RKOrderedDictionary.h in Headers */, + 250DF25F14C680F90001DEFA /* RKObjectMappingProvider+Contexts.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -1777,6 +1782,7 @@ 254A62BA14AD544200939BEE /* RKObjectPaginator.h in Headers */, 2513504F14B8FE6B00A7E893 /* RKConfigurationDelegate.h in Headers */, 250DF22B14C5190E0001DEFA /* RKOrderedDictionary.h in Headers */, + 250DF26014C680F90001DEFA /* RKObjectMappingProvider+Contexts.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/Specs/ObjectMapping/RKObjectLoaderSpec.m b/Specs/ObjectMapping/RKObjectLoaderSpec.m index 30899687..fb841e78 100644 --- a/Specs/ObjectMapping/RKObjectLoaderSpec.m +++ b/Specs/ObjectMapping/RKObjectLoaderSpec.m @@ -155,7 +155,7 @@ - (void)testShouldLoadAComplexUserObjectWithTargetObject { RKSpecComplexUser* user = [[RKSpecComplexUser new] autorelease]; - RKObjectManager* objectManager = [RKObjectManager objectManagerWithBaseURL:RKSpecGetBaseURL()]; + RKObjectManager* objectManager = [RKObjectManager managerWithBaseURL:RKSpecGetBaseURL()]; RKSpecResponseLoader* responseLoader = [RKSpecResponseLoader responseLoader]; RKObjectLoader* objectLoader = [objectManager loaderWithResourcePath:@"/JSON/ComplexNestedUser.json"]; objectLoader.delegate = responseLoader; @@ -174,7 +174,7 @@ } - (void)testShouldLoadAComplexUserObjectWithoutTargetObject { - RKObjectManager* objectManager = [RKObjectManager objectManagerWithBaseURL:RKSpecGetBaseURL()]; + RKObjectManager* objectManager = [RKObjectManager managerWithBaseURL:RKSpecGetBaseURL()]; RKSpecResponseLoader* responseLoader = [RKSpecResponseLoader responseLoader]; RKObjectLoader* objectLoader = [objectManager loaderWithResourcePath:@"/JSON/ComplexNestedUser.json"]; objectLoader.delegate = responseLoader; @@ -190,7 +190,7 @@ } - (void)testShouldLoadAComplexUserObjectUsingRegisteredKeyPath { - RKObjectManager* objectManager = [RKObjectManager objectManagerWithBaseURL:RKSpecGetBaseURL()]; + RKObjectManager* objectManager = [RKObjectManager managerWithBaseURL:RKSpecGetBaseURL()]; RKSpecResponseLoader* responseLoader = [RKSpecResponseLoader responseLoader]; RKObjectLoader* objectLoader = [objectManager loaderWithResourcePath:@"/JSON/ComplexNestedUser.json"]; objectLoader.delegate = responseLoader; @@ -225,7 +225,7 @@ } - (void)testShouldInvokeWillSendWithObjectLoaderOnSendAsynchronously { - RKObjectManager* objectManager = [RKObjectManager objectManagerWithBaseURL:RKSpecGetBaseURL()]; + RKObjectManager* objectManager = [RKObjectManager managerWithBaseURL:RKSpecGetBaseURL()]; [objectManager setMappingProvider:[self providerForComplexUser]]; RKSpecComplexUser* user = [[RKSpecComplexUser new] autorelease]; id mockObject = [OCMockObject partialMockForObject:user]; @@ -242,7 +242,7 @@ } - (void)testShouldInvokeWillSendWithObjectLoaderOnSendSynchronously { - RKObjectManager* objectManager = [RKObjectManager objectManagerWithBaseURL:RKSpecGetBaseURL()]; + RKObjectManager* objectManager = [RKObjectManager managerWithBaseURL:RKSpecGetBaseURL()]; [objectManager setMappingProvider:[self providerForComplexUser]]; RKSpecComplexUser* user = [[RKSpecComplexUser new] autorelease]; id mockObject = [OCMockObject partialMockForObject:user]; @@ -458,7 +458,7 @@ [userMapping mapAttributes:@"firstname", nil]; RKSpecComplexUser* user = [[RKSpecComplexUser new] autorelease]; - RKObjectManager* objectManager = [RKObjectManager objectManagerWithBaseURL:RKSpecGetBaseURL()]; + RKObjectManager* objectManager = [RKObjectManager managerWithBaseURL:RKSpecGetBaseURL()]; RKSpecResponseLoader* responseLoader = [RKSpecResponseLoader responseLoader]; RKObjectLoader* objectLoader = [objectManager loaderWithResourcePath:@"/JSON/ComplexNestedUser.json"]; @@ -481,7 +481,7 @@ [userMapping mapAttributes:@"firstname", nil]; RKSpecComplexUser* user = [[RKSpecComplexUser new] autorelease]; - RKObjectManager* objectManager = [RKObjectManager objectManagerWithBaseURL:RKSpecGetBaseURL()]; + RKObjectManager* objectManager = [RKObjectManager managerWithBaseURL:RKSpecGetBaseURL()]; RKSpecResponseLoader* responseLoader = [RKSpecResponseLoader responseLoader]; RKObjectMappingProvider *mappingProvider = [RKObjectMappingProvider mappingProvider]; [mappingProvider setObjectMapping:userMapping forResourcePathPattern:@"/JSON/ComplexNestedUser.json"]; @@ -506,7 +506,7 @@ [userMapping mapAttributes:@"firstname", nil]; RKSpecComplexUser* user = [[RKSpecComplexUser new] autorelease]; - RKObjectManager* objectManager = [RKObjectManager objectManagerWithBaseURL:RKSpecGetBaseURL()]; + RKObjectManager* objectManager = [RKObjectManager managerWithBaseURL:RKSpecGetBaseURL()]; RKSpecResponseLoader* responseLoader = [RKSpecResponseLoader responseLoader]; RKObjectMappingProvider *mappingProvider = [RKObjectMappingProvider mappingProvider]; [mappingProvider setObjectMapping:userMapping forResourcePathPattern:@"/JSON/:name\\.json"]; diff --git a/Specs/ObjectMapping/RKObjectManagerSpec.m b/Specs/ObjectMapping/RKObjectManagerSpec.m index 841ccf01..92422d3d 100644 --- a/Specs/ObjectMapping/RKObjectManagerSpec.m +++ b/Specs/ObjectMapping/RKObjectManagerSpec.m @@ -170,7 +170,7 @@ - (void)testShouldHandleConnectionFailures { NSString* localBaseURL = [NSString stringWithFormat:@"http://127.0.0.1:3001"]; - RKObjectManager* modelManager = [RKObjectManager objectManagerWithBaseURLString:localBaseURL]; + RKObjectManager* modelManager = [RKObjectManager managerWithBaseURLString:localBaseURL]; modelManager.client.requestQueue.suspended = NO; RKSpecResponseLoader* loader = [RKSpecResponseLoader responseLoader]; [modelManager loadObjectsAtResourcePath:@"/JSON/humans/1" delegate:loader]; diff --git a/Specs/Runner/RKSpecEnvironment.m b/Specs/Runner/RKSpecEnvironment.m index 121ff699..1c873f35 100644 --- a/Specs/Runner/RKSpecEnvironment.m +++ b/Specs/Runner/RKSpecEnvironment.m @@ -64,7 +64,7 @@ RKOAuthClient* RKSpecNewOAuthClient(RKSpecResponseLoader* loader){ RKObjectManager* RKSpecNewObjectManager(void) { [RKObjectMapping setDefaultDateFormatters:nil]; - RKObjectManager* objectManager = [RKObjectManager objectManagerWithBaseURL:RKSpecGetBaseURL()]; + RKObjectManager* objectManager = [RKObjectManager managerWithBaseURL:RKSpecGetBaseURL()]; [RKObjectManager setSharedManager:objectManager]; [RKClient setSharedClient:objectManager.client]; diff --git a/Tools/rkkeypath b/Tools/rkkeypath index 28960fb3..821f6998 100755 Binary files a/Tools/rkkeypath and b/Tools/rkkeypath differ