3

I am trying to get images into the ImageSlideshow with SDWebImage. I can get the images but can't format them. I hope I am making sense.

let url="https://myoscapp.com/boot/json_procuct_info.php"
    Alamofire.request(url, method: .get).validate().responseJSON { response in
        switch response.result {
        case .success(let value):
          let json = JSON(value)               
          let   imageslider=json[0]["products_gallery"].array
          if json[0]["products_gallery"].array != nil {
               let imageQuantity=imageslider?.count

               var i = 0
                    while i < imageQuantity! {

            let individualimage=imageslider?[i]["image"].stringValue


                        print(individualimageUrl!)
                        i=i+1
                    }


            }
swimfar
  • 147
  • 6
Frank Khan
  • 55
  • 8

1 Answers1

4

Let try this to add SDWebImage to ImageSlideshow

Create outlet for your slideshow

@IBOutlet var slideshow: ImageSlideshow!

With your Example :

var imageSDWebImageSrc = [SDWebImageSource]()

let url="https://myoscapp.com/boot/json_procuct_info.php"
    Alamofire.request(url, method: .get).validate().responseJSON { response in
        switch response.result {
        case .success(let value):
          let json = JSON(value)               
          let   imageslider = json[0]["products_gallery"].array
          if json[0]["products_gallery"].array != nil {
               for url in imageslider{
                   let image = SDWebImageSource(urlString: url)
                   if let sdURL = image{
                     imageSDWebImageSrc.append(sdURL)
                   }
               }
              self.slideshow.setImageInputs(self.imageSDWebImageSrc)
          }
        }
    } 

in Addition:

How to set ImageSlideshow image sources for ImageSource, SDWebImage, AFURLSource, AlamofireSource, KingfisherSource.

Update: You have to install it.

pod "ImageSlideshow/SDWebImage"

Run pod install

Pranavan SP
  • 1,785
  • 1
  • 17
  • 33
  • if let details = json2["imgs"].array { for dItem in details { let img = dItem["img"].stringValue self.logoImages.append(self.imgurl+img) // Cannot convert value of type 'String' to expected argument type 'SDWebImageSource' imageSDWebImageSrc.append(self.imgurl+img) } self.slideshow.setImageInputs(self.imageSDWebImageSrc) } – Venkatesh May 22 '18 at 09:38
  • have to add this line. check answer again let image = SDWebImageSource(urlString: url) – Pranavan SP May 22 '18 at 09:49
  • Showing error in this line : imageSDWebImageSrc.append(self.imgurl+img) // Cannot convert value of type 'String' to expected argument type 'SDWebImageSource' – Venkatesh May 22 '18 at 09:50