Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 07-20-2011, 02:30 PM   #1 (permalink)
Registered Member
 
Join Date: Apr 2009
Posts: 18
bobby456 is on a distinguished road
Default How to remove the associated UIProgressview with the right request ?

I use asihttprequest to download multiple files and I'm wondering how I can remove the associated UIProgressview with the right request when the download is done.

NSMutableArray *contentArray contains the ASIHTTPRequest and NSMutableArray *progArray contains my custom UIProgressview.

Code:
-(void)addDownload:(NSString *)theURL withName:(NSString *)fileName
{
theProgress = [[PDColoredProgressView alloc] initWithFrame:CGRectMake(3, 17, 314, 14)];
//...
ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:[NSURL URLWithString:theURL]];
//..
[request setDelegate:self];
    [request setDownloadProgressDelegate:theProgress];
    request.allowResumeForFileDownloads = YES;
    [request startAsynchronous];
    [request setShouldContinueWhenAppEntersBackground:YES];
    [contentArray addObject:request];
    [progArray addObject:theProgress];
    [theProgress retain];

    [self.tableView reloadData];
}

- (void)requestFinished:(ASIHTTPRequest *)request{

        [contentArray removeObject:request]; 
        [progArray removeObject:theProgress]; 
        NSLog(@"%@",progArray);
        NSLog(@"%@",contentArray);
        [self reloadMyData]; 
        [self.tableView reloadData]; 


        }
The problem is that this code remove the last progressview even if the there are 3 downloads in contentArray and the second one finish first. Can you help me with this ?
bobby456 is offline   Reply With Quote
Old 07-20-2011, 03:32 PM   #2 (permalink)
Senior Member
iPhone Dev SDK Supporter
 
Join Date: Aug 2008
Location: Memphis, TN, USA
Age: 24
Posts: 3,983
smithdale87 is on a distinguished road
Send a message via AIM to smithdale87
Default

use the ASIHTTPRequest's userInfo property to save your progressview with the request

Then, when the request is finished, you can look at the userinfo to get that progress view back


Code:
...
[request.userInfo setObject: theProgress forKey:@"ProgressView"];
...

PDColoredProgressView * progressView = [request.userInfo objectForKey: @"ProgressView"];
[progressView removeFromSuperview];
smithdale87 is offline   Reply With Quote
Old 07-20-2011, 03:50 PM   #3 (permalink)
Registered Member
 
Join Date: Apr 2009
Posts: 18
bobby456 is on a distinguished road
Default

Thanks !

What can you suggest me for calculate the speed of each download (asihttpresquest) accurately because [ASIHTTPRequest averageBandwidthUsedPerSecond] gives me an average ... ?

Quote:
Originally Posted by smithdale87 View Post
use the ASIHTTPRequest's userInfo property to save your progressview with the request

Then, when the request is finished, you can look at the userinfo to get that progress view back


Code:
...
[request.userInfo setObject: theProgress forKey:@"ProgressView"];
...

PDColoredProgressView * progressView = [request.userInfo objectForKey: @"ProgressView"];
[progressView removeFromSuperview];
bobby456 is offline   Reply With Quote
Old 07-20-2011, 04:37 PM   #4 (permalink)
Senior Member
iPhone Dev SDK Supporter
 
Join Date: Aug 2008
Location: Memphis, TN, USA
Age: 24
Posts: 3,983
smithdale87 is on a distinguished road
Send a message via AIM to smithdale87
Default

Do you just want the speed of the download to be calculated when the download is complete? Or do you need the speed to be constantly updated while the download is in progress?
smithdale87 is offline   Reply With Quote
Old 07-20-2011, 04:46 PM   #5 (permalink)
Registered Member
 
Join Date: Apr 2009
Posts: 18
bobby456 is on a distinguished road
Default

I need the speed to be constantly updated while the download is in progress...
How could I achieve that ?

Quote:
Originally Posted by smithdale87 View Post
Do you just want the speed of the download to be calculated when the download is complete? Or do you need the speed to be constantly updated while the download is in progress?
bobby456 is offline   Reply With Quote
Old 07-21-2011, 05:25 PM   #6 (permalink)
Registered Member
 
Join Date: Apr 2009
Posts: 18
bobby456 is on a distinguished road
Default

Anyone can help me to achieve that ?
bobby456 is offline   Reply With Quote
Old 07-22-2011, 03:24 AM   #7 (permalink)
Nuisance Developer
 
Join Date: Jul 2009
Location: Italy
Posts: 4,691
dany_dev is on a distinguished road
Default

check the official documentation....
ASIHTTPRequest example code - All-Seeing Interactive
__________________
dany_dev is offline   Reply With Quote
Reply

Bookmarks

Tags
ios, nsmutablearray, uiprogressview, uitableview

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 406
15 members and 391 guests
7twenty7, blasterbr, buggen, Clouds, dre, EvilElf, HemiMG, jeroenkeij, jimmyon122, jonathandeknudt, LEARN2MAKE, n00b, nyoe, pungs, UMAD
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,668
Threads: 94,121
Posts: 402,901
Top Poster: BrianSlick (7,990)
Welcome to our newest member, jonathandeknudt
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 03:57 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0