Last active
February 11, 2016 11:27
-
-
Save trevorah/0bb72a677f8afbc03753 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MasterViewController: UITableViewController { | |
let cache = NSCache() | |
override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) { | |
if let indexPath = tableView.indexPathForSelectedRow { | |
let object = objects[indexPath.row] as! NSDate | |
let controller = cache.objectForKey(object) as? DetailViewController ?? (storyboard?.instantiateViewControllerWithIdentifier("DetailViewController"))! as! DetailViewController | |
cache.setObject(controller, forKey: object) | |
controller.detailItem = object | |
controller.navigationItem.leftBarButtonItem = self.splitViewController?.displayModeButtonItem() | |
controller.navigationItem.leftItemsSupplementBackButton = true | |
navigationController!.popToRootViewControllerAnimated(false) | |
navigationController!.pushViewController(controller, animated: true) | |
} | |
} | |
... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment