1

My progress indicator is not working in cocoa webview I used this code -

   -(void)download:(NSURLDownload *)download didReceiveResponse:(NSURLResponse *)response { 
                 NSLog(@"downl didreceiveresponse here"); 
                 NSLog(@"Recieved reponse with expected length: %lli", [response expectedContentLength]); 
                payload=0; 
                [payload setLength:0]; 
                [progrssbar setMaxValue:[response expectedContentLength]] ; 
                [self setProgrssbar:progrssbar]; 
        } 
            - (void)connection:(NSURLConnection *)conn didReceiveData:(NSData *)data 
        { 
              NSLog(@"Recieving data. Incoming Size: %li Total Size: %li", (unsigned long)[data length], (unsigned long)[payload length]); 
              [payload appendData:data]; 
              [progrssbar setDoubleValue:[payload length]]; 
         } 
  - (void)download:(NSURLDownload *)download didReceiveDataOfLength:(unsigned)length 
   { 
            NSLog(@"downl receivedata here%i",length); 
            [progrssbar setHidden:NO]; 
            [progrssbar setIndeterminate:NO]; 
            [progrssbar startAnimation:self]; 
            [progrssbar setDoubleValue:(double)length]; [progrssbar displayIfNeeded];
     }
Mike Abdullah
  • 14,933
  • 2
  • 50
  • 75
Sierra
  • 337
  • 3
  • 15

1 Answers1

1

What exactly is payload declared as? I used a similar code where I declared NSMutableData *payload and then in -(void)download:(NSURLDownload *)download didReceiveResponse:(NSURLResponse *)response I used payload=[NSMutableData data] instead of your payload=0, maybe that is the problem?

Nickkk
  • 2,261
  • 1
  • 25
  • 34
  • from this your progress bar downloaded fully? – Sierra Apr 25 '13 at 05:11
  • Actually I used the delegate methods `- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response`, `- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data`, `- (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error` and `- (void)connectionDidFinishLoading:(NSURLConnection *)connection`, I would try substituting these to the first and the third method you use. – Nickkk Apr 25 '13 at 06:25