@@ -84,10 +84,10 @@ - (void) sendRequest:(NSMutableURLRequest *)request
8484 else {
8585 info = [QNSessionManager buildResponseInfo: httpResponse withError: error withDuration: duration withResponse: data withHost: host];
8686 }
87- [progress removeObserver: self forKeyPath: @" fractionCompleted" context: (__bridge void *)(progressBlock)];
8887 completeBlock (info, resp);
88+ [progress removeObserver: self forKeyPath: @" completedUnitCount" context: (__bridge void *)(progressBlock)];
8989 }];
90- [progress addObserver: self forKeyPath: @" fractionCompleted " options: NSKeyValueObservingOptionNew context: (__bridge void *)(progressBlock)];
90+ [progress addObserver: self forKeyPath: @" completedUnitCount " options: NSKeyValueObservingOptionNew context: (__bridge void *)(progressBlock)];
9191
9292 [request setTimeoutInterval: kQNTimeoutInterval ];
9393
@@ -97,15 +97,13 @@ - (void) sendRequest:(NSMutableURLRequest *)request
9797}
9898
9999- (void )observeValueForKeyPath : (NSString *)keyPath ofObject : (id )object change : (NSDictionary *)change context : (void *)context {
100- if ([keyPath isEqualToString: @" fractionCompleted" ]) {
101- NSProgress *progress = (NSProgress *)object;
102- QNInternalProgressBlock progressBlock = (__bridge QNInternalProgressBlock)context;
103- if (progress != nil && progressBlock != nil ) {
104- progressBlock (progress.completedUnitCount , progress.totalUnitCount );
105- }
100+ if (context == nil ) {
101+ return ;
106102 }
107- else {
108- [super observeValueForKeyPath: keyPath ofObject: object change: change context: context];
103+ NSProgress *progress = (NSProgress *)object;
104+ QNInternalProgressBlock progressBlock = (__bridge QNInternalProgressBlock)context;
105+ if (progress != nil && progressBlock != nil ) {
106+ progressBlock (progress.completedUnitCount , progress.totalUnitCount );
109107 }
110108}
111109
0 commit comments