Last active
February 21, 2020 04:20
-
-
Save cmoulton/5c06cc57d525e377f65aabacd07e21a8 to your computer and use it in GitHub Desktop.
Revisions
-
cmoulton renamed this gist
Apr 12, 2016 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
cmoulton created this gist
Apr 2, 2016 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,95 @@ // // DetailViewController.swift // objcInterop // // Created by Christina Moulton on 2015-07-02. // Copyright (c) 2015 Teak Mobile Inc. All rights reserved. // import UIKit import DZNEmptyDataSet class DetailViewController: UIViewController, UITableViewDelegate, UITableViewDataSource, DZNEmptyDataSetSource, DZNEmptyDataSetDelegate { @IBOutlet weak var tableView: UITableView? var objects = [AnyObject]() var detailItem: AnyObject? { didSet { // Update the view. self.configureView() } } func configureView() { // Update the user interface for the detail item. tableView?.emptyDataSetSource = self tableView?.emptyDataSetDelegate = self // A little trick for removing the cell separators self.tableView?.tableFooterView = UIView() } deinit { self.tableView?.emptyDataSetSource = nil self.tableView?.emptyDataSetDelegate = nil } override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view, typically from a nib. self.configureView() } override func didReceiveMemoryWarning() { super.didReceiveMemoryWarning() // Dispose of any resources that can be recreated. } // MARK: - Table View func numberOfSectionsInTableView(tableView: UITableView) -> Int { return 1 } func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int { return objects.count } func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { let cell = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath) let object = objects[indexPath.row] as! NSDate cell.textLabel!.text = object.description return cell } func tableView(tableView: UITableView, canEditRowAtIndexPath indexPath: NSIndexPath) -> Bool { // Return false if you do not want the specified item to be editable. return true } func tableView(tableView: UITableView, commitEditingStyle editingStyle: UITableViewCellEditingStyle, forRowAtIndexPath indexPath: NSIndexPath) { if editingStyle == .Delete { objects.removeAtIndex(indexPath.row) tableView.deleteRowsAtIndexPaths([indexPath], withRowAnimation: .Fade) self.tableView?.reloadEmptyDataSet() } else if editingStyle == .Insert { // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view. } } // MARK: - DZNEmptyDataSetSource, DZNEmptyDataSetDelegate func titleForEmptyDataSet(scrollView: UIScrollView!) -> NSAttributedString! { return NSAttributedString(string: "Got nothin'") } func descriptionForEmptyDataSet(scrollView: UIScrollView!) -> NSAttributedString! { return NSAttributedString(string: "Sorry about this, I'm just all out of data") } func emptyDataSetShouldDisplay(scrollView: UIScrollView!) -> Bool { return objects.count == 0 } }