diff --git a/Classes/ASIHTTPRequest.m b/Classes/ASIHTTPRequest.m index e38345bf..d984dd3d 100644 --- a/Classes/ASIHTTPRequest.m +++ b/Classes/ASIHTTPRequest.m @@ -997,7 +997,8 @@ - (void)setUploadProgressDelegate:(id)newDelegate [[self cancelledLock] lock]; uploadProgressDelegate = newDelegate; - + +#if !TARGET_OS_IPHONE // If the uploadProgressDelegate is an NSProgressIndicator, we set it's MaxValue to 1.0 so we can treat it similarly to UIProgressViews SEL selector = @selector(setMaxValue:); if ([uploadProgressDelegate respondsToSelector:selector]) { @@ -1010,6 +1011,7 @@ - (void)setUploadProgressDelegate:(id)newDelegate [invocation invoke]; } +#endif [[self cancelledLock] unlock]; } @@ -1018,7 +1020,8 @@ - (void)setDownloadProgressDelegate:(id)newDelegate [[self cancelledLock] lock]; downloadProgressDelegate = newDelegate; - + +#if !TARGET_OS_IPHONE // If the downloadProgressDelegate is an NSProgressIndicator, we set it's MaxValue to 1.0 so we can treat it similarly to UIProgressViews SEL selector = @selector(setMaxValue:); if ([downloadProgressDelegate respondsToSelector:selector]) { @@ -1029,6 +1032,7 @@ - (void)setDownloadProgressDelegate:(id)newDelegate [invocation setArgument:&max atIndex:2]; [invocation invokeWithTarget:downloadProgressDelegate]; } +#endif [[self cancelledLock] unlock]; } @@ -1142,7 +1146,6 @@ - (void)resetDownloadProgress:(unsigned long long)value - (void)updateDownloadProgress { - // We won't update download progress until we've examined the headers, since we might need to authenticate if ([self responseHeaders] && ([self contentLength] || [self complete])) { @@ -1220,7 +1223,8 @@ + (void)setProgress:(double)progress forProgressIndicator:(id)indicator SEL selector; [progressLock lock]; - + +#if TARGET_OS_IPHONE // Cocoa Touch: UIProgressView if ([indicator respondsToSelector:@selector(setProgress:)]) { selector = @selector(setProgress:); @@ -1229,23 +1233,19 @@ + (void)setProgress:(double)progress forProgressIndicator:(id)indicator [invocation setSelector:selector]; float progressFloat = (float)progress; // UIProgressView wants a float for the progress parameter [invocation setArgument:&progressFloat atIndex:2]; - - // If we're running in the main thread, update the progress straight away. Otherwise, it's not that urgent [invocation performSelectorOnMainThread:@selector(invokeWithTarget:) withObject:indicator waitUntilDone:[NSThread isMainThread]]; - - + } +#else // Cocoa: NSProgressIndicator - } else if ([indicator respondsToSelector:@selector(setDoubleValue:)]) { + if ([indicator respondsToSelector:@selector(setDoubleValue:)]) { selector = @selector(setDoubleValue:); NSMethodSignature *signature = [[indicator class] instanceMethodSignatureForSelector:selector]; NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:signature]; [invocation setSelector:selector]; [invocation setArgument:&progress atIndex:2]; - - [invocation performSelectorOnMainThread:@selector(invokeWithTarget:) withObject:indicator waitUntilDone:[NSThread isMainThread]]; - } +#endif [progressLock unlock]; } diff --git a/Classes/ASINetworkQueue.m b/Classes/ASINetworkQueue.m index c1b96fde..ee749439 100644 --- a/Classes/ASINetworkQueue.m +++ b/Classes/ASINetworkQueue.m @@ -87,7 +87,8 @@ - (void)cancelAllOperations - (void)setUploadProgressDelegate:(id)newDelegate { uploadProgressDelegate = newDelegate; - + +#if !TARGET_OS_IPHONE // If the uploadProgressDelegate is an NSProgressIndicator, we set it's MaxValue to 1.0 so we can treat it similarly to UIProgressViews SEL selector = @selector(setMaxValue:); if ([[self uploadProgressDelegate] respondsToSelector:selector]) { @@ -97,14 +98,16 @@ - (void)setUploadProgressDelegate:(id)newDelegate [invocation setSelector:selector]; [invocation setArgument:&max atIndex:2]; [invocation invokeWithTarget:[self uploadProgressDelegate]]; - } + } +#endif } - (void)setDownloadProgressDelegate:(id)newDelegate { downloadProgressDelegate = newDelegate; - + +#if !TARGET_OS_IPHONE // If the downloadProgressDelegate is an NSProgressIndicator, we set it's MaxValue to 1.0 so we can treat it similarly to UIProgressViews SEL selector = @selector(setMaxValue:); if ([[self downloadProgressDelegate] respondsToSelector:selector]) { @@ -114,7 +117,8 @@ - (void)setDownloadProgressDelegate:(id)newDelegate [invocation setSelector:@selector(setMaxValue:)]; [invocation setArgument:&max atIndex:2]; [invocation invokeWithTarget:[self downloadProgressDelegate]]; - } + } +#endif } - (void)addHEADOperation:(NSOperation *)operation