i am getting images from the .net web server by passing xml parameters.
i am getting more that 20 images and i am saving images in iphone simulator documents one by one like this.
-(void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName
{
if( [elementName isEqualToString:@"photo"])
{
recordResults_photo = FALSE;
NSData *decode = [Base64 decode:resultData_photo];
NSString *theXML = [[NSString alloc] initWithData:decode encoding:NSUTF8StringEncoding];
NSData *decodedimage = [Base64 decode:theXML];
UIImage *image = [UIImage imageWithData:decodedimage];
NSString *docDir = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
NSLog(@"saving msg image %d",i);
NSString *pngFilePath = [NSString stringWithFormat:@"%@/image%d.png",docDir,i];
NSData *data1 = [NSData dataWithData:UIImagePNGRepresentation(image)];
[data1 writeToFile:pngFilePath atomically:YES];
}
}
then images are saving like this image0.png,image1.png,image2.png.....
and i am displaying these images in table view like this.
NSString *docDir = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
NSString *pngFilePath = [NSString stringWithFormat:@"%@/image%d.png",docDir,indexPath.row];
UIImageView *img = [[UIImageView alloc]initWithFrame:CGRectMake(250, 05, 30, 30)];
img.image = [UIImage imageWithContentsOfFile:pngFilePath];
[cell.contentView addSubview:img];
then images are displayed well.
But now i have a problem here.
I am getting some more new images from the web server and i need to display them at the top of the table view.
As per my implementation i need to change all the image names.
That's not the proper way,is there any alternate way or better way than me.
can any one please help me.
Thank u in advance