我有一个名为“ComLog”的“UIImage”返回类型方法。我想从这个方法返回一个图像。在“ComLog”方法中,我使用 GCD 从数组中获取图像值。我使用以下代码,"NSLog(@"qqqqqqqqqq %@", exiIco)" 打印 'image' 值,但 NSLog(@"qqqqqqqqqq %@", exiIco);" 不打印。这是详细信息:
-(UIImage*) ComLog
{
ExibitorInfo *currentExibitor100 = [[ExibitorInfo alloc] init];
currentExibitor100 = [self.exibitorsArray objectAtIndex:0];
imageQueueCompanyLogo = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0ul);
dispatch_async(imageQueueCompanyLogo, ^
{
UIImage *imageCompanyLogo = [UIImage imageWithData:[NSData dataWithContentsOfURL: [NSURL URLWithString:[currentExibitor100 companyLogoURL]]]];
dispatch_async(dispatch_get_main_queue(), ^
{
self.exibitorIcoImageView.image = imageCompanyLogo;
exiIco = imageCompanyLogo;
NSLog(@"qqqqqqqqqqq %@", exiIco);
});
});
return exiIco;
}
- (void)viewDidLoad
{
[super viewDidLoad];
UIImage *a = [self ComLog];
NSLog(@"It should be a image %@", a);
}
这里所有的属性都是全局声明的(在“Myclass.h”文件中)。我是Objective C的新手。如果您知道答案,请回复。提前致谢。