我正在开发一款iPhone应用,我需要在for循环中使用图片网址从服务器下载100-200张图片。如下:
NSOperationQueue *queue = [NSOperationQueue new];
NSInvocationOperation *operation = [[NSInvocationOperation alloc] initWithTarget:self
selector:@selector(downloadImages:)
object:arrayTemp];
[queue addOperation:operation];
[operation release];
[queue release];
-(void)downloadImages{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc]init];
UIImage *image;
for (int i=0; i < [self.ImagesRecords count]; i++)
{
ImageData *data =(ImageData*) [self.ImagesRecords objectAtIndex:i];
NSString *strName = [NSString stringWithFormat:@"image_%@",data.ID];
image = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:[@"http://abc.com" stringByAppendingString:data.PhotoPath]]]];
if (image!=nil)
{
[self saveImage:image withName:strName];
}
}
image = nil;
[pool release];
}
它的工作正常并给我形象。
我的问题是:
答案 0 :(得分:0)
<xml>
<info>
<width>55</width>
<height>41</height>
</info>
<image_data>
<data>
<name>Background</name>
<data>data:image/png;base64,iVBORw0KGgoAAA...</data>
</data>
<data>
<name>Layer #2</name>
<data>data:image/png;base64,iVBORw0KGgoAAAANS...</data>
</data>
<data>
<name>Layer #3</name>
<data>data:image/png;base64,iVBORw0KGgoAAAANSUh...</data>
</data>
</image_data>
</xml>