Skip to content

Instantly share code, notes, and snippets.

@ymkjp
Created September 24, 2015 12:11
Show Gist options
  • Select an option

  • Save ymkjp/89fd7cb76c95f36a9e77 to your computer and use it in GitHub Desktop.

Select an option

Save ymkjp/89fd7cb76c95f36a9e77 to your computer and use it in GitHub Desktop.
NewsPlayer/ViewController.swift
diff --git a/NewsPlayer/ViewController.swift b/NewsPlayer/ViewController.swift
index 55fe627..ecdcd7e 100644
--- a/NewsPlayer/ViewController.swift
+++ b/NewsPlayer/ViewController.swift
@@ -205,9 +205,13 @@ class ViewController: UIViewController, UITableViewDataSource, UITableViewDelega
}
func initVideoCell(indexPath: NSIndexPath) -> VideoTableViewCell {
- videoTable.registerNib(UINib(nibName: cellName, bundle:nil), forCellReuseIdentifier:cellName)
- return videoTable.dequeueReusableCellWithIdentifier(
- cellName, forIndexPath: indexPath) as! VideoTableViewCell
+ if let _ = videoTable.dequeueReusableCellWithIdentifier(cellName) {
+ return videoTable.dequeueReusableCellWithIdentifier(
+ cellName, forIndexPath: indexPath) as! VideoTableViewCell
+ } else {
+ videoTable.registerNib(UINib(nibName: cellName, bundle:nil), forCellReuseIdentifier:cellName)
+ return initVideoCell(indexPath)
+ }
}
func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment