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 > iPhone SDK Development - Advanced Discussion

Reply
 
LinkBack Thread Tools Display Modes
Old 07-13-2011, 10:17 PM   #1 (permalink)
Registered Member
 
Join Date: Apr 2011
Posts: 24
Rabbit is on a distinguished road
Default ASIHTTPRequest and stop download request?

Hi all,

I am using this code to download an image from internet then view it at UIIviewImage, the question how to stop the download of the image any time? becasue right now when I request the download the button will stay pressed until the image complete the download : (


-(IBAction) baa:(id) sender{
ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:[NSURL URLWithString:@"http://upload.wikimedia.org/wikipedia/commons/thumb/a/a5/Flower_poster_2.jpg/451px-Flower_poster_2.jpg"]];
NSString *mediaPath = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents"];
mediaPath = [mediaPath stringByAppendingPathComponent:@"log_2.jpg"];
[request setDownloadDestinationPath:mediaPath];
[request startSynchronous];
NSLog(@"File Pathe in local: %@", mediaPath);
// Create file manager
NSError *error;
NSFileManager *fileMgr = [NSFileManager defaultManager];
// Point to Document directory
NSString *documentsDirectory = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents"];
// Write out the contents of home directory to console
NSLog(@"Documents directory: %@", [fileMgr contentsOfDirectoryAtPath:documentsDirectory error:&error]);
imgV.image = [UIImage imageWithContentsOfFile:mediaPath];
}



Kind Regards,
Rabbit
Rabbit is offline   Reply With Quote
Old 07-14-2011, 01:46 AM   #2 (permalink)
Nuisance Developer
 
Join Date: Jul 2009
Location: Italy
Posts: 4,691
dany_dev is on a distinguished road
Default

this is not advanced....

however, read the documentation: ASIHTTPRequest example code - All-Seeing Interactive

Quote:
To cancel an asynchronous request (either a request that was started with [request startAsynchronous] or a request running in a queue you created), call [request cancel]. Note that you cannot cancel a synchronous request.
Code:
// Cancels an asynchronous request
[request cancel]
 
// Cancels an asynchronous request, clearing all delegates and blocks first
[request clearDelegatesAndCancel];
__________________
dany_dev is offline   Reply With Quote
Old 07-14-2011, 05:32 AM   #3 (permalink)
Registered Member
 
Join Date: Apr 2011
Posts: 24
Rabbit is on a distinguished road
Default

Thank you dany_dev it is working right now !

Thank you again : )


Rabbit
Rabbit is offline   Reply With Quote
Old 03-05-2012, 04:00 AM   #4 (permalink)
New User
 
Join Date: Feb 2012
Posts: 5
dineshprasanna is on a distinguished road
Default

Thank you sir: )
dineshprasanna is offline   Reply With Quote
Reply

Bookmarks

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: 383
17 members and 366 guests
Absentia, AyClass, Diligent, dre, givensur, hussain1982, jbro, jPuzzle, momolgtm, Newbie123, Paul10, revg, skog, skrew88, taylor202, tomtom100
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,643
Threads: 94,110
Posts: 402,858
Top Poster: BrianSlick (7,990)
Welcome to our newest member, Diligent
Powered by vBadvanced CMPS v3.1.0

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