서버에서 수천 장의 사진 (최대 350KB)을 다운로드하려고하는데 "Memory Presure"라는 경고 메시지가 나타납니다. 기본적으로메모리 부족으로 많은 이미지 다운로드
나는 모든 이미지의 이름과 배열을 가지고 루프는 다음과 같이 하나 하나를 가지고 않습니다
for (int x=0; x<unique.count; x++) {
NSURL *ImageLink = [NSURL URLWithString:[NSString stringWithFormat:@"http://urltoimagesfolder.com/", [unique objectAtIndex:x]]];
NSData *data = [NSData dataWithContentsOfURL:ImageLink];
UIImage *img = [[UIImage alloc] initWithData:data];
if (data.length !=0) {
NSString *fullPath = [documentsDirectory stringByAppendingPathComponent:[unique objectAtIndex:x]]; //add our image to the path
[UIImageJPEGRepresentation(img, 1.0) writeToFile:fullPath atomically:YES];
//[self saveImage:img :NombreFoto];
//[self Miniatura:img :[NSString stringWithFormat:@"mini-%@", [unique objectAtIndex:x]]];
}
data = nil;
img = nil;
}
질문 :와 응용 프로그램 충돌없이 모든 이미지를 다운로드 할 수있는 방법 기억력?
무엇이 당신의 질문입니까? – rocky
편집 메모리 압박으로 앱이 충돌하지 않고 모든 이미지를 어떻게 다운로드 할 수 있습니까? –
음 ... 작성한 후에 img을 출시 하시겠습니까? – rocky