http://blog.ios-developers.io/view-controller-extensions/

UITableView. Along with the code that provides custom functionality, your view controller will need to conform to the UITableView

// ViewController.swift
class ViewController: UIViewController {  
    override func viewDidLoad() {
        super.viewDidLoad()
        // Extra view initializations go here...
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
    }

    // DataSource
    func numberOfSectionsInTableView(tableview: UITableView) -> Int {
        return 1
    }

    func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return Data.dataStore.count
    }

    func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath)

        let row = indexPath.row
        cell.textLabel?.text = Data.dataStore[row]

        return cell
    }

    // Delegate
    func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
        let row = indexPath.row
        print(Data.dataStore[row])
    }
}

//colorfulcomments or MARK organization in order to add visual separation from the rest of your code. But what if there was a way to just move all of that code into its own file? Good news everyone, there is! All we need are some handy extensions.

Welcome to the Extension Zone

Extensions allow you to extend the functionality of a class, structure, enumeration, or protocol type. Say you wanted to add a custom method to the NSString class. Extensions let you do that. Or maybe you want to separate out some code, say in a view controller, into a different file. Extensions let you do that! Just take the code from before and bring it out into it's own file. This is demonstrated as follows.

ViewController.swift
class ViewController: UIViewController {  
    override func viewDidLoad() {
        super.viewDidLoad()
        // Extra view initializations go here...
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
    }
}
ViewController+DataSource.swift
extension ViewController: UITableViewDataSource {  
    func numberOfSectionsInTableView(tableview: UITableView) -> Int {
        return 1
    }

    func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return Data.dataStore.count
    }

    func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath)

        let row = indexPath.row
        cell.textLabel?.text = Data.dataStore[row]

        return cell
    }
}
ViewController+Delegate.swift
extension ViewController: UITableViewDelegate {  
    func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
        let row = indexPath.row
        print(Data.dataStore[row])
    }
}

Voilà. Now all of the code related to the DataSource and Delegate protocols are contained within their own files. These methods are isolated from the rest of your view controller, yet they still provide the essential capabilities to your program. Just look at how clean that view controller is now!

ctrl+drag

Now you're all set. Sporting a sleek, slimmed down VC!