I try to do TableViewController and TableCell have an image.
While the row can load image of web, I directly call my own custom function of UIImageView.
And then I just set image and show it while requestDidFininshed.
But now, I have a problem that this method is happen
Error Domain=ASIHTTPRequestErrorDomain Code=6 "Unable to start HTTP connection" UserInfo=0x6a48880 {NSLocalizedDescription=Unable to start HTTP connection}
So I need somebody help me to solve this problem. Thanks.
// UIImageView+AsyncLoadImage.h
#import <Foundation/Foundation.h>
@interface UIImageView (AsyncLoadImage)
-(void)asyncLoadWithNSURL:(NSURL *)url;
@end
// UIImageView+AsyncLoadImage.m
#import "UIImageView+AsyncLoadImage.h"
#import "ASIHTTPRequest.h"
@implementation UIImageView (AsyncLoadImage)
-(void)requestFinished:(ASIHTTPRequest *)request
{
NSData *data = [request responseData];
[self.image initWithData:data];
}
-(void)requestFailed:(ASIHTTPRequest *)request
{
NSError *error = [request error];
NSLog(@"error: %@", [error description]);
}
-(void)asyncLoadWithNSURL:(NSURL *)url
{
ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url];
[request setDelegate:self];
[request startAsynchronous];
}
@end