Ich versuche, Web-Service auf iOS zu lernen.Ziel-C: Bild von JSON
Ich fange an, ein Bild von einem JSON API Link zu bekommen.
Ich habe den Code unten verwendet, aber das Bild angezeigt wird nicht, und ich bin Warnung erhalten, die Typen die Zuordnung zu ‚UIImage * _Nullable‘ von ‚NSSting * _Nullable‘
Inkompatible Zeiger sagt
Mein Code
NSURL *urlAdPop = [NSURL URLWithString:@"JSON LINK HERE"];
NSURLRequest *request = [NSURLRequest requestWithURL:urlAdPop];
[NSURLConnection sendAsynchronousRequest:request
queue:[NSOperationQueue mainQueue]
completionHandler:^(NSURLResponse *response,
NSData *data, NSError *connectionError)
{
if (data.length > 0 && connectionError == nil)
{
NSDictionary *AdPopUp = [NSJSONSerialization JSONObjectWithData:data
options:0
error:NULL];
popUpBanner.image = [[AdPopUp objectForKey:@"ad_image"] stringValue];
popUpAdURL = [AdPopUp objectForKey:@"ad_link"];
}
}];
popUpBanner.image = [UIImage imageWithData:[NSData dataWithContentsOfURL:popUpAdURL]];
popUpBanner.hidden = NO;
popUpBanner.layer.cornerRadius = 9;
popUpBanner.clipsToBounds = YES;
popUpBanner.userInteractionEnabled = YES;
[self.view addSubview:popUpBanner];
:) hilft, wenn Sie Blockoperationen wie sendAsynchronousRequest verwenden, sollten Sie Ihren Code setzen, die für diese –