How to Display Images Quickly from url in iphone

My project is based on rating pictures. I want to know the best way to display images quickly in imageview from the link without memory leakage and without any crash. Since, in the future the images can be in the order of hundreds of thousands and I will have to display these images. Is it necessary to download the picture first??? If anyone has knowledge about it then please provide me some solutions.

Thanks to all in advance.


You can download the pictures asynchronously from the internet, which keeps the App responsive. There is already a solution for that, for example by calling the method

[yourAsynchronousImageView loadImageFromURLString:@"http://your.url/image.jpg"];


#import <UIKit/UIKit.h>

@interface AsynchronousImageView : UIImageView {
    NSURLConnection *connection;    
    NSMutableData *data;
    bool loading;

@property bool loading;

- (void)loadImageFromURLString:(NSString *)theUrlString;



#import "AsynchronousImageView.h"

@implementation AsynchronousImageView
@synthesize loading;

- (id)initWithFrame:(CGRect)frame
    self = [super initWithFrame:frame];
    if (self) {
        // Initialization code
    return self;

- (void)loadImageFromURLString:(NSString *)theUrlString{ 
    self.image = nil;
    NSURLRequest *request = [NSURLRequest requestWithURL:
                             [NSURL URLWithString:theUrlString]
    connection = [[NSURLConnection alloc]
                  initWithRequest:request delegate:self];

- (void)connection:(NSURLConnection *)theConnection
    didReceiveData:(NSData *)incrementalData {    if (data == nil)
        data = [[NSMutableData alloc] initWithCapacity:2048];                 

    [data appendData:incrementalData];}

- (void)connectionDidFinishLoading:(NSURLConnection *)theConnection {    
    self.image = [UIImage imageWithData:data];
    data = nil; 
    connection = nil;

// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect
    // Drawing code


Need Your Help

Inserts into Sybase table in the cursor fetch loop

tsql sybase sybase-ase

I am writing a Sybase stored procedure with a cursor fetching records from table and inserting records back. Surprisingly I found that fetches see amd return records inserted in the same loop. Unde...