Added sharedNetworkQueue, a singleton-like queue that will save you having to manage queues yourself
Showing
2 changed files
with
12 additions
and
0 deletions
@@ -83,6 +83,9 @@ | @@ -83,6 +83,9 @@ | ||
83 | // This method will start the queue | 83 | // This method will start the queue |
84 | - (void)go; | 84 | - (void)go; |
85 | 85 | ||
86 | +// A globally available network queue, created the first time it is requested | ||
87 | ++ (ASINetworkQueue *)sharedNetworkQueue; | ||
88 | + | ||
86 | @property (assign,setter=setUploadProgressDelegate:) id uploadProgressDelegate; | 89 | @property (assign,setter=setUploadProgressDelegate:) id uploadProgressDelegate; |
87 | @property (assign,setter=setDownloadProgressDelegate:) id downloadProgressDelegate; | 90 | @property (assign,setter=setDownloadProgressDelegate:) id downloadProgressDelegate; |
88 | 91 |
@@ -9,6 +9,7 @@ | @@ -9,6 +9,7 @@ | ||
9 | #import "ASINetworkQueue.h" | 9 | #import "ASINetworkQueue.h" |
10 | #import "ASIHTTPRequest.h" | 10 | #import "ASIHTTPRequest.h" |
11 | 11 | ||
12 | +static ASINetworkQueue *sharedNetworkQueue = nil; | ||
12 | 13 | ||
13 | @implementation ASINetworkQueue | 14 | @implementation ASINetworkQueue |
14 | 15 | ||
@@ -288,6 +289,14 @@ | @@ -288,6 +289,14 @@ | ||
288 | } | 289 | } |
289 | 290 | ||
290 | 291 | ||
292 | ++ (ASINetworkQueue *)sharedNetworkQueue | ||
293 | +{ | ||
294 | + if (!sharedNetworkQueue) { | ||
295 | + sharedNetworkQueue = [[ASINetworkQueue alloc] init]; | ||
296 | + } | ||
297 | + return sharedNetworkQueue; | ||
298 | +} | ||
299 | + | ||
291 | 300 | ||
292 | @synthesize uploadProgressDelegate; | 301 | @synthesize uploadProgressDelegate; |
293 | @synthesize downloadProgressDelegate; | 302 | @synthesize downloadProgressDelegate; |
-
Please register or login to post a comment