Skip to content

Commit

Permalink
Fix iPhone progress updates
Browse files Browse the repository at this point in the history
  • Loading branch information
pokeb committed Apr 13, 2010
1 parent 7580b7b commit 7ff7761
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 13 deletions.
27 changes: 16 additions & 11 deletions Classes/ASIHTTPRequest.m
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@


// Automatically set on build
NSString *ASIHTTPRequestVersion = @"v1.6.1-11 2010-04-13";
NSString *ASIHTTPRequestVersion = @"v1.6.1-12 2010-04-13";

NSString* const NetworkRequestErrorDomain = @"ASIHTTPRequestErrorDomain";

Expand Down Expand Up @@ -1434,8 +1434,20 @@ + (void)performSelector:(SEL)selector onTarget:(id)target withObject:(id)object

+ (void)updateProgressIndicator:(id)indicator withProgress:(unsigned long long)progress ofTotal:(unsigned long long)total
{

#if TARGET_OS_IPHONE
// Cocoa Touch: UIProgressView
float progressAmount;
SEL selector = @selector(setProgress:);
#else
// Cocoa: NSProgressIndicator
double progressAmount;
SEL selector = @selector(setDoubleValue:);
#endif
if (![indicator respondsToSelector:selector]) {
return;
}


//Workaround for an issue with converting a long to a double on iPhone OS 2.2.1 with a base SDK >= 3.0
if ([ASIHTTPRequest isiPhoneOS2]) {
progressAmount = [[NSNumber numberWithUnsignedLongLong:progress] doubleValue]/[[NSNumber numberWithUnsignedLongLong:total] doubleValue];
Expand All @@ -1446,13 +1458,7 @@ + (void)updateProgressIndicator:(id)indicator withProgress:(unsigned long long)p
[progressLock lock];


#if TARGET_OS_IPHONE
// Cocoa Touch: UIProgressView
SEL selector = @selector(setProgress:);
#else
// Cocoa: NSProgressIndicator
SEL selector = @selector(setDoubleValue:);
#endif

[ASIHTTPRequest performSelector:selector onTarget:indicator withObject:nil args:&progressAmount,nil];
[progressLock unlock];
}
Expand Down Expand Up @@ -2461,8 +2467,7 @@ - (void)handleBytesAvailable
[invocation setArgument:self atIndex:2];
[invocation setArgument:[NSData dataWithBytes:buffer length:bytesRead] atIndex:3];
[invocation performSelectorOnMainThread:@selector(invokeWithTarget:) withObject:[self delegate] waitUntilDone:[NSThread isMainThread]];



// Are we downloading to a file?
} else if ([self downloadDestinationPath]) {
if (![self fileDownloadOutputStream]) {
Expand Down
1 change: 0 additions & 1 deletion Classes/ASIHTTPRequestDelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
// Copyright 2010 All-Seeing Interactive. All rights reserved.
//

#import <Cocoa/Cocoa.h>
@class ASIHTTPRequest;

@protocol ASIHTTPRequestDelegate <NSObject>
Expand Down
1 change: 0 additions & 1 deletion Classes/ASIProgressDelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
// Copyright 2010 All-Seeing Interactive. All rights reserved.
//

#import <Cocoa/Cocoa.h>
@class ASIHTTPRequest;

@protocol ASIProgressDelegate <NSObject>
Expand Down
4 changes: 4 additions & 0 deletions iPhone.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,8 @@
B565291E101C8BD7000499CF /* ASITestCase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ASITestCase.h; sourceTree = "<group>"; };
B565291F101C8BD7000499CF /* ASITestCase.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ASITestCase.m; sourceTree = "<group>"; };
B56529A2101C8EDA000499CF /* iphone-tests-icon.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "iphone-tests-icon.png"; path = "iPhone Sample/iphone-tests-icon.png"; sourceTree = "<group>"; };
B5747F271174BB8300C9414E /* ASIHTTPRequestDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ASIHTTPRequestDelegate.h; sourceTree = "<group>"; };
B5747F281174BB8300C9414E /* ASIProgressDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ASIProgressDelegate.h; sourceTree = "<group>"; };
B5873FC110FF28CA001E145F /* ASIS3BucketObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ASIS3BucketObject.h; sourceTree = "<group>"; };
B5873FC210FF28CA001E145F /* ASIS3BucketObject.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ASIS3BucketObject.m; sourceTree = "<group>"; };
B5873FC510FF28CA001E145F /* ASIS3Request.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ASIS3Request.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -235,6 +237,8 @@
isa = PBXGroup;
children = (
B551DB4610D6938500EC1CBF /* ASIHTTPRequestConfig.h */,
B5747F271174BB8300C9414E /* ASIHTTPRequestDelegate.h */,
B5747F281174BB8300C9414E /* ASIProgressDelegate.h */,
B59A87C0103EC6F200300252 /* ASIAuthenticationDialog.h */,
B59A87C1103EC6F200300252 /* ASIAuthenticationDialog.m */,
B522DACC1030B2AB009A2D22 /* ASIInputStream.h */,
Expand Down

0 comments on commit 7ff7761

Please sign in to comment.