Last active
August 29, 2015 14:22
-
-
Save ydn/67f67fe60d51396cda93 to your computer and use it in GitHub Desktop.
Flurry iOS Native Ad view composition
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: (); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
nativeAd.space
andnativeAd.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.