Best way to retrieve Image from Server

Discussion in 'iOS Programming' started by man2manno, Jan 2, 2011.

  1. man2manno macrumors member

    Joined:
    Mar 21, 2009
    #1
    Hey guys, so I have a question on which method would be better to use for a situation where I have an image stored on my server and I want to retrieve it back to a UIImage from my iphone app. I have the image uploaded and I also stored it as a BLOB type on my server.

    My question is, is it better to keep the image as a BLOB and try and retrieve it from that type from my application(if so how?), or is it better just to save the link (address of the image) as a string and use NSURLDownload to retrieve the image?

    Thanks a lot for the help.
     
  2. jnoxx macrumors 65816

    jnoxx

    Joined:
    Dec 29, 2010
    Location:
    Aartselaar // Antwerp // Belgium
    #2
    I think it was u who also was on iphoneDevsdk, with the same question.
    So read there ;)
    U can get the URL, and then download it like that into ur UIImage



    Code:
    NSData* imageData = [[NSData alloc]initWithContentsOfURL:[NSURL URLWithString:[promotion picture_small_nl]]];
    //Instead of the promotion picture_small_nl, use ur custom link with @" " or ur array like me ;)
    	//NSLog(@"show imageData : %s", imageData);
    	//NSLog(@"show urlstring: %@", [promotion picture_small_nl]);
    	[detailViewController promotionView].image = [[UIImage alloc] initWithData:imageData];
    //Here I define the imageview with the image.
    or go like [self blahImageView].image = [[UIImage alloc] initWithData:imageData
    good luck
     

Share This Page