Swift-Snips

The goal here isn't to simply show how you would manage data read into an array from a model class, and then use it to populate cells in a table view.

// Created by Chris Cantley on 11/13/14.// Copyright (c) 2014 Chris Cantley. All rights reserved.//importFoundationimportUIKitimportCoreDataclassLendersViewController: UIViewController {
//lenders is the array we are going to stick our data intovarlenders=Array<Lenders>()
// This is the lendersModel class. This contains our read/write/udpate/delete methods. For this example we will use a read method to load the table.letlendersModel=LendersModel()
//MARK: VC Delegate MethodsoverridefuncviewDidLoad()
// Get the data from the read function in the lendersModel class when the view loads. self.lenders=lendersModel.readLenderData() asArray
}
}
// This extension focusses on containing delegate and custom methods specific to the table view.extensionLendersViewController: UITableViewDelegate, UITableViewDataSource {
functableView(tableView: UITableView, numberOfRowsInSectionsection: Int) ->Int {
//return lenderData.count!returnself.lenders.count
}
functableView(tableView: UITableView, cellForRowAtIndexPathindexPath: NSIndexPath) ->UITableViewCell{
// Set the cell to reference the LendersViewCell class below.// This contains all the connections to the cell.letcell: UITableViewCell=tableView.dequeueReusableCellWithIdentifier(“SomeCell") as UITableViewCellvarlendersNSArray=lendersasNSArrayvargetData=lendersNSArray[indexPath.row].valueForKey("corpName") asString?println(getData!)
returncell
}
}