I am trying to display JSON data in my tableview cell based on objects with the same value.
Right now, I am able to display ALL the JSON data into my cell rows, but I am unable to exclude data that doesn't have the same object value.
I'm using this setup to get the data:
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
// Retrieve cell
let cellIdentifier: String = "takesTableViewCell"
let myCell: TakesTableViewCell = tableView.dequeueReusableCell(withIdentifier: cellIdentifier)! as! TakesTableViewCell
// Get the location to be shown
let item: LocationModel = feedItems[indexPath.row] as! LocationModel
// Get references to labels of cell
myCell.mainNameLabel.text = item.title
myCell.mainTakeLabel.text = item.take
return myCell
}
Here's sample JSON data I have
[
{
"id":"1",
"title":"Great Title 1",
"take":"Testing !!!",
"movieid":"299534"
},
{
"id":"2",
"title":"Great Title 2",
"take":"Testing 1,2,3",
"movieid":"299666"
},
{
"id":"3",
"title":"Great Title 3",
"take":"Testing 1,2,3",
"movieid":"299534"
}
]
I only want to display the results that have the same "movieid" like so:
Title: Great Title 1
Take: Testing !!!
Title: Great Title 3
Take: Testing 1,2,3