{"id":1157,"date":"2017-10-06T11:36:30","date_gmt":"2017-10-06T02:36:30","guid":{"rendered":"http:\/\/blue-bear.jp\/kb\/?p=1157"},"modified":"2017-10-15T15:30:06","modified_gmt":"2017-10-15T06:30:06","slug":"swift-tableviewcontroller-template","status":"publish","type":"post","link":"https:\/\/blue-bear.jp\/kb\/swift-tableviewcontroller-template\/","title":{"rendered":"[swift] tableViewController Template"},"content":{"rendered":"<p>Here is template for tableViewController<\/p>\n<p>on Storyboard, ViewController + TableView + TableViewCell should be setup<\/p>\n<p>on TableViewCell, setup &#8220;tableCell&#8221; as ID<\/p>\n<pre>import UIKit\r\n\r\nclass testTableViewContoller: UIViewController, UITableViewDelegate, UITableViewDataSource{\r\n    \r\n    @IBOutlet weak var tableView: UITableView!\r\n    let array:[String] = [\"swift\",\"Ruby\",\"Rails\",\"PHP\",\"HTML.CSS\",\"JS\",\"Java\"]\r\n    \r\n    override func viewDidLoad() {\r\n        super.viewDidLoad()\r\n\r\n        \/\/ Delegate Setting\r\n        tableView.dataSource = self\r\n        tableView.delegate = self\r\n        \r\n    }\r\n    \r\n    \r\n    override func didReceiveMemoryWarning() {\r\n        super.didReceiveMemoryWarning()\r\n    }\r\n    \r\n    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -&gt; Int {\r\n        \/\/ Amount of Cell for 1 section\r\n        return array.count\r\n    }\r\n    \r\n    \r\n    func numberOfSections(in tableView: UITableView) -&gt; Int { \r\n        \/\/ Amount of Section\r\n        return 1\r\n    }\r\n    \r\n    func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -&gt; CGFloat {\r\n        \/\/ Cell Height\r\n        return 50\r\n    }\r\n    \r\n    \r\n    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -&gt; UITableViewCell {\r\n        \r\n        \/\/ Cell Detail Setting\r\n        let cell = tableView.dequeueReusableCell(withIdentifier: \"tableCell\", for: indexPath)\r\n        cell.textLabel?.text = array[indexPath.row]\r\n        \r\n        return cell\r\n        \r\n    } \r\n\r\n\r\n    func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {\r\n\r\n    \/\/Selected Method\r\n\r\n    }\r\n}\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Here is template for<\/p>\n","protected":false},"author":1,"featured_media":88,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[13],"tags":[],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/blue-bear.jp\/kb\/wp-json\/wp\/v2\/posts\/1157"}],"collection":[{"href":"https:\/\/blue-bear.jp\/kb\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blue-bear.jp\/kb\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blue-bear.jp\/kb\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blue-bear.jp\/kb\/wp-json\/wp\/v2\/comments?post=1157"}],"version-history":[{"count":2,"href":"https:\/\/blue-bear.jp\/kb\/wp-json\/wp\/v2\/posts\/1157\/revisions"}],"predecessor-version":[{"id":1210,"href":"https:\/\/blue-bear.jp\/kb\/wp-json\/wp\/v2\/posts\/1157\/revisions\/1210"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blue-bear.jp\/kb\/wp-json\/wp\/v2\/media\/88"}],"wp:attachment":[{"href":"https:\/\/blue-bear.jp\/kb\/wp-json\/wp\/v2\/media?parent=1157"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blue-bear.jp\/kb\/wp-json\/wp\/v2\/categories?post=1157"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blue-bear.jp\/kb\/wp-json\/wp\/v2\/tags?post=1157"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}