Browse files

Removed references to sharedQueue from Advanced Tutorial sources

  • Loading branch information...
1 parent 6ed37f0 commit 12bacf9be414cdcdf08b5b3562de49111b8d86bd @blakewatters blakewatters committed Sep 8, 2011
View
17 Code/ObjectMapping/RKObjectMapping.m
@@ -14,9 +14,6 @@
// Constants
NSString* const RKObjectMappingNestingAttributeKeyName = @"<RK_NESTING_ATTRIBUTE>";
-// Default NSTimeZone
-static NSTimeZone* defaultTimeZone = nil;
-
@implementation RKObjectMapping
@synthesize objectClass = _objectClass;
@@ -29,20 +26,6 @@ @implementation RKObjectMapping
@synthesize forceCollectionMapping = _forceCollectionMapping;
@synthesize performKeyValueValidation = _performKeyValueValidation;
-+ (NSTimeZone *)defaultTimeZone {
- if (defaultTimeZone) {
- return defaultTimeZone;
- } else {
- return [NSTimeZone defaultTimeZone];
- }
-}
-
-+ (void)setDefaultTimeZone:(NSTimeZone *)timeZone {
- [timeZone retain];
- [defaultTimeZone release];
- defaultTimeZone = timeZone;
-}
-
+ (id)mappingForClass:(Class)objectClass {
RKObjectMapping* mapping = [self new];
mapping.objectClass = objectClass;
View
12 Docs/MobileTuts Advanced RestKit/Advanced_RestKit_Tutorial.md
@@ -88,7 +88,7 @@ Memory management can become very tiresome in Cocoa applications, as so much wor
}
}
-Notice that there isn't a single call to retain, release or autorelease anywhere in sight. This is where the request queue comes into play. When we ask to send an RKRequest object, it isn't immediately dispatched. Instead it is retained by the RKRequestQueue sharedQueue instance and sent as soon as possible. RestKit watches for notifications generated by RKRequest & RKResponse and releases its hold on the request after processing has completed. This allows us to work with web services with very little thought about the memory management.
+Notice that there isn't a single call to retain, release or autorelease anywhere in sight. This is where the request queue comes into play. When we ask to send an RKRequest object, it isn't immediately dispatched. Instead it is retained by the RKClient's requestQueue instance and sent as soon as possible. RestKit watches for notifications generated by RKRequest & RKResponse and releases its hold on the request after processing has completed. This allows us to work with web services with very little thought about the memory management.
In addition to retaining & releasing RKRequest instances, RKRequestQueue also serves as a gatekeeper to the network access itself. When the application is first launched or returns from a background state, RestKit uses its integration with the System Configuration Reachability API's to determine if any network access is available. When talking to a remote server by hostname, there can be a delay between launch and the determination of network availability. During this time, RestKit is in an indeterminate reachability state and RKRequestQueue will defer sending any requests until network reachability can be determined. Once reachability is determined, RKRequestQueue prevents the network from becoming overburdened by limiting the number of concurrent requests to five.
@@ -97,25 +97,25 @@ Once your user interfaces begin spanning multiple controllers and users are navi
- (void)viewWillAppear:(BOOL)animated {
/**
* Ask RKClient to load us some data. This causes an RKRequest object to be created
- * transparently pushed onto the RKRequestQueue sharedQueue instance
+ * transparently pushed onto [RKClient sharedClient].requestQueue instance
*/
- [RKClient sharedClient] get:@"/some/data.json" delegate:self];
+ [[RKClient sharedClient] get:@"/some/data.json" delegate:self];
}
// We have been dismissed -- clean up any open requests
- (void)dealloc {
- [[RKRequestQueue sharedQueue] cancelRequestsWithDelegate:self];
+ [[RKClient sharedClient].requestQueue cancelRequestsWithDelegate:self];
[super dealloc];
}
// We have been obscured -- cancel any pending requests
- (void)viewWillDisappear:(BOOL)animated {
- [[RKRequestQueue sharedQueue] cancelRequestsWithDelegate:self];
+ [[RKClient sharedClient].requestQueue cancelRequestsWithDelegate:self];
}
Rather than managing the request ourselves and doing the housekeeping, we can just ask RKRequestQueue to cancel any requests that we are the delegate for. If there are none currently processing, no action will be taken.
-A sharedQueue singleton instance is created for you at framework initialization time. It is also possible to create additional ad-hoc queues to manage groups of requests
+A requestQueue instance is created for you at RKClient initialization time. It is also possible to create additional ad-hoc queues to manage groups of requests
more granularly. For example, an ad-hoc queue could be useful for downloading or uploading content in the background, while keeping the main shared queue free for responding to user actions. Let's take a look at an example of using an ad-hoc queue:
- (IBAction)queueRequests {

0 comments on commit 12bacf9

Please sign in to comment.