[Solved] Populating UITableView with JSON data from youtube videos in Swift 2 and Xcode 7


You first have to create a UITable and implement the delegate methods together with a custom class that will act as cell for the UITable if you dont want the the deafult behaviour of the class.

For passing the data to the details you will use something called the segue you can have a look at the below project on github.

As for getting the data from youtube you will probably get a json response from youtube which you have to decode and add the objects to a list. You then just assign the object to the coressponding element like the below.

    //the view of every cell of the list
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {

    //custom cell identifier
    let cell = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath) as! ViewControllerCell

    //setting up the images and casting them from strings to UIImages
    let imageURL = NSURL(string: JSONGameImages[indexPath.row])
    let data = NSData(contentsOfURL: imageURL!)

    //setting game name, images and viewers on cells
    cell.gameName?.text = JSONGameName[indexPath.row]
    cell.gameViewers?.text = String (JSONViewers[indexPath.row])
    cell.gameImage?.image = UIImage(data: data!)


    return cell
}

https://github.com/renegens/Greenely

4

solved Populating UITableView with JSON data from youtube videos in Swift 2 and Xcode 7