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