Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Added newRequestQueueWithName to the API

  • Loading branch information...
commit 0640f20bd2cde671168381c7e9e66a3239e15475 1 parent 84032d9
Blake Watters blakewatters authored
6 Code/Network/RKRequestQueue.h
@@ -97,6 +97,12 @@
97 97 + (id)requestQueue;
98 98
99 99 /**
  100 + Returns a new retained request queue with the given name. If there is already
  101 + an existing queue with the given name, nil will be returned.
  102 + */
  103 ++ (id)newRequestQueueWithName:(NSString*)name;
  104 +
  105 +/**
100 106 Returns queue with the specified name. If no queue is found with
101 107 the name provided, a new queue will be initialized and returned.
102 108 */
16 Code/Network/RKRequestQueue.m
@@ -65,6 +65,22 @@ + (id)requestQueue {
65 65 return [[self new] autorelease];
66 66 }
67 67
  68 ++ (id)newRequestQueueWithName:(NSString*)name {
  69 + if (RKRequestQueueInstances == nil) {
  70 + RKRequestQueueInstances = [NSMutableArray new];
  71 + }
  72 +
  73 + if ([self requestQueueExistsWithName:name]) {
  74 + return nil;
  75 + }
  76 +
  77 + RKRequestQueue* queue = [self new];
  78 + queue.name = name;
  79 + [RKRequestQueueInstances addObject:[NSValue valueWithNonretainedObject:queue]];
  80 +
  81 + return queue;
  82 +}
  83 +
68 84 + (id)requestQueueWithName:(NSString *)name {
69 85 if (RKRequestQueueInstances == nil) {
70 86 RKRequestQueueInstances = [NSMutableArray new];
13 Specs/Network/RKRequestQueueSpec.m
@@ -188,4 +188,17 @@ - (void)itShouldRemoveTheQueueFromTheNamedInstancesOnDealloc {
188 188 assertThatBool([RKRequestQueue requestQueueExistsWithName:@"Images5"], is(equalToBool(NO)));
189 189 }
190 190
  191 +- (void)itShouldReturnANewOwningReferenceViaNewRequestWithName {
  192 + RKRequestQueue* requestQueue = [RKRequestQueue newRequestQueueWithName:@"Images6"];
  193 + assertThat(requestQueue, isNot(nilValue()));
  194 + assertThatInt([requestQueue retainCount], is(equalToInt(1)));
  195 +}
  196 +
  197 +- (void)itShouldReturnNilIfNewRequestQueueWithNameIsCalledForAnExistingName {
  198 + RKRequestQueue* queue = [RKRequestQueue newRequestQueueWithName:@"Images7"];
  199 + assertThat(queue, isNot(nilValue()));
  200 + RKRequestQueue* queue2 = [RKRequestQueue newRequestQueueWithName:@"Images7"];
  201 + assertThat(queue2, is(nilValue()));
  202 +}
  203 +
191 204 @end

0 comments on commit 0640f20

Please sign in to comment.
Something went wrong with that request. Please try again.