Skip to content

Instantly share code, notes, and snippets.

@mchirico
Last active August 29, 2015 14:06
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 mchirico/b6adb967a586cbaedeb2 to your computer and use it in GitHub Desktop.
Save mchirico/b6adb967a586cbaedeb2 to your computer and use it in GitHub Desktop.
UITableViewDataSource for Xcode 6b7. They changed a few things
//
// MainViewController.swift
// AddEvents
//
// Created by Michael Chirico on 9/6/14.
// Copyright (c) 2014 Michael Chirico. All rights reserved.
//
import UIKit
import CoreData
class MainViewController: UIViewController, UITableViewDataSource {
@IBOutlet weak var tableViewCell0: UITableView!
var data = ["one","two","three","four"]
var count=0
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
}
override func viewDidAppear(animated: Bool) {
tableViewCell0.reloadData()
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
func numberOfSectionsInTableView(tableView: UITableView!) -> Int {
// #warning Potentially incomplete method implementation.
// Return the number of sections.
return 1
}
func tableView(tableView: UITableView,
cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
//let cell = UITableViewCell(style: UITableViewCellStyle.Value2, reuseIdentifier: nil)
let cell = UITableViewCell(style: UITableViewCellStyle.Subtitle, reuseIdentifier: "Cell0")
cell.detailTextLabel!.text = "DETAIL"
cell.textLabel!.text = data[indexPath.item]
return cell
}
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
println("data count \(data.count)")
return data.count
}
/*
func sectionIndexTitlesForTableView(tableView: UITableView!) {
}
*/
/*
// MARK: - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
override func prepareForSegue(segue: UIStoryboardSegue!, sender: AnyObject!) {
// Get the new view controller using segue.destinationViewController.
// Pass the selected object to the new view controller.
}
*/
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment