Skip to content

Instantly share code, notes, and snippets.

@ydn
Last active August 29, 2015 14:22
Show Gist options
  • Save ydn/67f67fe60d51396cda93 to your computer and use it in GitHub Desktop.
Save ydn/67f67fe60d51396cda93 to your computer and use it in GitHub Desktop.
Flurry iOS Native Ad view composition
func adNativeDidFetchAd(nativeAd: FlurryAdNative!) {
NSLog("Native Ad for Space \(nativeAd.space) Received Ad with \(nativeAd.assetList.count) assets");
for asset in nativeAd.assetList {
switch(asset.name) {
case "headline":
streamTitleLabel.text = asset.value;
case "summary":
streamDescriptionLabel.text = asset.value;
case "secImage":
if let url = NSURL(string: asset.value!!) {
if let imageData = NSData(contentsOfURL: url) {
streamImageView.image = UIImage(data: imageData);
}
}
case "source":
streamSourceLabel.text = asset.value;
case "secHqBrandingLogo":
if let url = NSURL(string: asset.value!!) {
if let imageData = NSData(contentsOfURL: url) {
streamSponsoredImageView.image = UIImage(data: imageData);
}
}
default: ();
}
}
}
@DrkSephy
Copy link

nativeAd.space and nativeAd.assetList will are guaranteed to be non-nil, as this method is a callback function which is called on successfully fetching an ad.

As for using the native for-in syntax, I'll update the gist with your respective changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment