Muhamméd Muhamméd - 6 months ago 111
Swift Question

Passing dynamic array to ImageSlideshow ios

Iam trying to use **ImageSlideshow
** library

and i followed the documentation step by step and it's working perfectly

but i can only pass static images and here's my code :

slideShow.setImageInputs([AFURLSource(urlString: "https://mylink.com/image.jpg")!, AFURLSource(urlString: "https://mylink.com/image2.jpg")!, AFURLSource(urlString: "https://mylink.com/image3.jpg")!])

But i need to get the images url from JSON array dynamically and pass it to slideshow like that :

var jsonArray:NSarray = [String]

slideShow.setImageInputs([jsonArray])


any idea how can i do that ?

Answer

try this :

let arr =  jsonArray.map { AFURLSource(urlString: $0 as! String)!}
slideShow.setImageInputs(arr)

hope it be helpful :-)