Tableview Feed Images

I developing news app. I using RSS feed with XML Parsing. I want RSS feed add images. I have defined the necessary function for images. But I do not know how to use a variable when I get the photo in RSS. My application is currently receiving the photo from the URL. All photos are the same. How can I do that? Sorry for my bad English.

//UItableView Data source
internal func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int
{
    return haberler.count
}

internal func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell
{
    var cell:EmojiTableViewCell = tableView.dequeueReusableCell(withIdentifier: "myCell")! as UITableViewCell as! EmojiTableViewCell

    if (cell.isEqual(NSNull.self))
    {
        cell = Bundle.main.loadNibNamed("myCell", owner: self, options: nil)?[0] as! UITableViewCell as! EmojiTableViewCell
    }

    let emojiTitle = (haberler.object(at: indexPath.row) as AnyObject).value(forKey: "title") as! NSString as String
    cell.emojiTitleLabel.text = emojiTitle.trimmingCharacters(in: .whitespaces)
    cell.emojiImageView.downloadFrom(link: "http://teknolojix.net/wp-content/uploads/2014/10/Below-is-a-rendering-of-the-page-up-to-the-first-error-hatası.jpg", contentMode: UIViewContentMode.scaleAspectFill)

    return cell
}

Your problem is very simple. you have pass the same link on the “downloadFrom” function. Please use “haberler” array to get the different image photo url. For example I used you above mentioned code to give you proper understanding.

CODE:

cell.emojiImageView.downloadFrom(link:haberler[indexPath.row].YOUR_PHOTO_URL_KEY_NAME, contentMode: UIViewContentMode.scaleAspectFill)

If you are not understand, please provide me “haberler” array so that I can give you proper solution with code.

Actually you are using hard-coded ‘URL’ to download image every time. You need to show image for every cell by getting different ‘URL’ from your data source same like you are getting ‘title’ for every cell. For example:

    let emojiImageURL = (haberler.object(at: indexPath.row) as AnyObject).value(forKey: "url") as! NSString as String
    cell.emojiImageView.downloadFrom(link: emojiImageURL, contentMode: UIViewContentMode.scaleAspectFill)