2
我有一段代码应该将图像添加到NSMutableArray
的问题。出于某种原因,图像不会被添加(数组的数量保持为0)。有人可以告诉我我在做什么错吗?添加UIImage到NSMutableArray
- (void)incomingNotification:(NSNotification *)notification {
[self.popoverController dismissPopoverAnimated:YES];
_URLString = [notification object];
for (int i = 0; i < [[self returnLargeUrls] count]; i++) {
[self getImageFromURL:_URLString];
}
}
而且在getImageFromUrl:
:
-(NSData *) getImageFromURL:(NSString *)fileURL {
UIImage *result;
NSData *data = [NSData dataWithContentsOfURL:[NSURL URLWithString:fileURL]];
result = [UIImage imageWithData:data];
[self.pageImages addObject:result];
NSLog(@"%d", self.pageImages.count);
return data;
}
wt是[self returnLargeUrls] ?? – iPatel 2013-03-25 14:10:24
NSLog你的getImageFromURL的结果确保它不是null,然后NSLog的returnLargeURLs的结果,并确保它不是空的。 – 2013-03-25 14:12:40