here I am having problem that I am able to get the data from json web services but unable to display on my ui in the program I mentioned where I am getting error and what it is
what you are using to display image in func swiped(gesture: UIGestureRecognizer)
method execution is as below
imageView.image = UIImage(named: imageArray[pageIndex])
but your image is comping from the server so you just need to display all images of your product is as you displayed first in OperationQueue.main.addOperation
so in place of displaying image using UIImage(named: imageArray[pageIndex])
you need to convert it to data and display it to imageview and your modified func swiped(gesture: UIGestureRecognizer)
may look like as below
func swiped(gesture: UIGestureRecognizer) {
if let swipeGesture = gesture as? UISwipeGestureRecognizer {
switch swipeGesture.direction {
case UISwipeGestureRecognizerDirection.right :
if pageIndex == 0 {
}else{
pageIndex -= 1
}
let imgURL = NSURL(string:self.imageArray[pageIndex])
let data = NSData(contentsOf: (imgURL as URL?)!)
self.imageView.image = UIImage(data: data! as Data)
case UISwipeGestureRecognizerDirection.left:
if pageIndex >= imageArray.count-1{
}else{
pageIndex += 1
}
let imgURL = NSURL(string:self.imageArray[pageIndex])
let data = NSData(contentsOf: (imgURL as URL?)!)
self.imageView.image = UIImage(data: data! as Data)
default:
break
}
}
}