Reputation: 3352
I have an array of URL's I am trying to load into an ImageView using KingFisher.
arrPageTitle = ["This is The App Guruz", "This is Table Tennis 3D", "This is Hide Secrets"];
arrPagePhoto = ["https://s3.amazonaws.com/fan-polls/heyward_again.jpg", "https://s3.amazonaws.com/fan-polls/Schwarber.jpg", "https://s3.amazonaws.com/fan-polls/mike_ditka.jpg"];
I am trying to load the appropriate image based on the index of the UIPageViewController:
pageContentViewController.imageView.kf_setImageWithURL((arrPagePhoto[index] as! String))
I am receiving `fatal error: unexpectedly found nil while unwrapping an Optional value
Any help is appreciated!
Upvotes: 0
Views: 1394
Reputation: 4708
As I know, kf_setImageWithURL
require NSURL, not String.
So convert arrPagePhoto[index]
to NSURL first then pass it to kf_setImageWithURL
:
let downloadURL: NSURL = NSURL(string: arrPagePhoto[index])!
pageContentViewController.imageView.kf_setImageWithURL(downloadURL)
Upvotes: 2