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
|