Skip to content

Instantly share code, notes, and snippets.

@benjamingr
Created August 22, 2014 08:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save benjamingr/a9125a17147ab21e6c30 to your computer and use it in GitHub Desktop.
Save benjamingr/a9125a17147ab21e6c30 to your computer and use it in GitHub Desktop.
import Foundation
import UIKit
class MyHomeView : UIView {
var stockTable:UITableView!
override init(frame:CGRect){
super.init(frame:frame)
stockTable = UITableView(frame: frame,style: UITableViewStyle.Plain)
stockTable.delegate = HomePageStockListCommands()
stockTable.dataSource = HomePageStockListSource()
stockTable.rowHeight = 45
stockTable.sectionFooterHeight = 0
stockTable.sectionHeaderHeight = 0
stockTable.scrollEnabled = true
stockTable.showsVerticalScrollIndicator = true
stockTable.userInteractionEnabled = true
stockTable.bounces = true
self.addSubview(self.stockTable) // this causes an EXC_BAD_ACCESS
}
}
class HomePageStockListCommands: NSObject, UITableViewDelegate {
}
class HomePageStockListSource : NSObject, UITableViewDataSource {
func tableView(tableView: UITableView!, numberOfRowsInSection section: Int) -> Int {
print("Request for size") // does not get printed
return 1
}
func tableView(tableView: UITableView!, cellForRowAtIndexPath indexPath: NSIndexPath!) -> UITableViewCell! {
print("Request for cell") // does not get printed
let cell = UITableViewCell()
println(cell.textLabel)
cell.textLabel.text = "MSFT"
return cell
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment