Make the queue pass on the authorization warning to its delegate
Showing
6 changed files
with
21 additions
and
9 deletions
| @@ -152,6 +152,14 @@ | @@ -152,6 +152,14 @@ | ||
| 152 | [ASIHTTPRequest setProgress:progress forProgressIndicator:downloadProgressDelegate]; | 152 | [ASIHTTPRequest setProgress:progress forProgressIndicator:downloadProgressDelegate]; |
| 153 | } | 153 | } |
| 154 | 154 | ||
| 155 | +- (void)authorizationNeededForRequest:(ASIHTTPRequest *)request | ||
| 156 | +{ | ||
| 157 | + if ([delegate respondsToSelector:@selector(authorizationNeededForRequest:)]) { | ||
| 158 | + [delegate performSelector:@selector(authorizationNeededForRequest:) withObject:request]; | ||
| 159 | + } | ||
| 160 | +} | ||
| 161 | + | ||
| 162 | + | ||
| 155 | @synthesize uploadProgressDelegate; | 163 | @synthesize uploadProgressDelegate; |
| 156 | @synthesize downloadProgressDelegate; | 164 | @synthesize downloadProgressDelegate; |
| 157 | @synthesize requestDidFinishSelector; | 165 | @synthesize requestDidFinishSelector; |
| @@ -43,10 +43,11 @@ | @@ -43,10 +43,11 @@ | ||
| 43 | - (IBAction)URLFetchWithProgress:(id)sender | 43 | - (IBAction)URLFetchWithProgress:(id)sender |
| 44 | { | 44 | { |
| 45 | [networkQueue cancelAllOperations]; | 45 | [networkQueue cancelAllOperations]; |
| 46 | + [networkQueue setDownloadProgressDelegate:progressIndicator]; | ||
| 47 | + [networkQueue setDelegate:self]; | ||
| 48 | + [networkQueue setRequestDidFinishSelector:@selector(URLFetchWithProgressComplete:)]; | ||
| 49 | + | ||
| 46 | ASIHTTPRequest *request = [[[ASIHTTPRequest alloc] initWithURL:[NSURL URLWithString:@"http://trails-network.net/Downloads/MemexTrails_1.0b1.zip"]] autorelease]; | 50 | ASIHTTPRequest *request = [[[ASIHTTPRequest alloc] initWithURL:[NSURL URLWithString:@"http://trails-network.net/Downloads/MemexTrails_1.0b1.zip"]] autorelease]; |
| 47 | - [request setDelegate:self]; | ||
| 48 | - [request setDownloadProgressDelegate:progressIndicator]; | ||
| 49 | - [request setDidFinishSelector:@selector(URLFetchWithProgressComplete:)]; | ||
| 50 | [request setDownloadDestinationPath:[[[[NSBundle mainBundle] bundlePath] stringByDeletingLastPathComponent] stringByAppendingPathComponent:@"MemexTrails_1.0b1.zip"]]; | 51 | [request setDownloadDestinationPath:[[[[NSBundle mainBundle] bundlePath] stringByDeletingLastPathComponent] stringByAppendingPathComponent:@"MemexTrails_1.0b1.zip"]]; |
| 51 | [networkQueue addOperation:request]; | 52 | [networkQueue addOperation:request]; |
| 52 | } | 53 | } |
| @@ -108,14 +109,17 @@ | @@ -108,14 +109,17 @@ | ||
| 108 | - (IBAction)fetchTopSecretInformation:(id)sender | 109 | - (IBAction)fetchTopSecretInformation:(id)sender |
| 109 | { | 110 | { |
| 110 | [networkQueue cancelAllOperations]; | 111 | [networkQueue cancelAllOperations]; |
| 112 | + [networkQueue setRequestDidFinishSelector:@selector(topSecretFetchComplete:)]; | ||
| 113 | + [networkQueue setDelegate:self]; | ||
| 114 | + | ||
| 111 | [progressIndicator setDoubleValue:0]; | 115 | [progressIndicator setDoubleValue:0]; |
| 116 | + | ||
| 112 | ASIHTTPRequest *request; | 117 | ASIHTTPRequest *request; |
| 113 | request = [[[ASIHTTPRequest alloc] initWithURL:[NSURL URLWithString:@"http://allseeing-i.com/top_secret/"]] autorelease]; | 118 | request = [[[ASIHTTPRequest alloc] initWithURL:[NSURL URLWithString:@"http://allseeing-i.com/top_secret/"]] autorelease]; |
| 114 | - [request setDelegate:self]; | ||
| 115 | - [request setDidFinishSelector:@selector(topSecretFetchComplete:)]; | ||
| 116 | [request setUseKeychainPersistance:[keychainCheckbox state]]; | 119 | [request setUseKeychainPersistance:[keychainCheckbox state]]; |
| 117 | [networkQueue addOperation:request]; | 120 | [networkQueue addOperation:request]; |
| 118 | 121 | ||
| 122 | + | ||
| 119 | } | 123 | } |
| 120 | 124 | ||
| 121 | - (IBAction)topSecretFetchComplete:(ASIHTTPRequest *)request | 125 | - (IBAction)topSecretFetchComplete:(ASIHTTPRequest *)request |
| @@ -47,12 +47,12 @@ | @@ -47,12 +47,12 @@ | ||
| 47 | if (img) { | 47 | if (img) { |
| 48 | if ([imageView1 image]) { | 48 | if ([imageView1 image]) { |
| 49 | if ([imageView2 image]) { | 49 | if ([imageView2 image]) { |
| 50 | - [imageView3 setImage:img]; | 50 | + [imageView3 performSelectorOnMainThread:@selector(setImage:) withObject:img waitUntilDone:NO]; |
| 51 | } else { | 51 | } else { |
| 52 | - [imageView2 setImage:img]; | 52 | + [imageView2 performSelectorOnMainThread:@selector(setImage:) withObject:img waitUntilDone:NO]; |
| 53 | } | 53 | } |
| 54 | } else { | 54 | } else { |
| 55 | - [imageView1 setImage:img]; | 55 | + [imageView1 performSelectorOnMainThread:@selector(setImage:) withObject:img waitUntilDone:NO]; |
| 56 | } | 56 | } |
| 57 | } | 57 | } |
| 58 | } | 58 | } |
This diff is collapsed. Click to expand it.
This diff could not be displayed because it is too large.
-
Please register or login to post a comment