Last active
August 29, 2015 14:06
-
-
Save mchirico/b6adb967a586cbaedeb2 to your computer and use it in GitHub Desktop.
UITableViewDataSource for Xcode 6b7. They changed a few things
This file contains 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 characters
// | |
// 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
Reference: http://stackoverflow.com/questions/24024466/how-do-i-make-a-class-conform-to-a-delegate-in-swift