DemoApp/DemoApp/ViewController.swift in xcmultilingual-0.1.6 vs DemoApp/DemoApp/ViewController.swift in xcmultilingual-0.1.7
- old
+ new
@@ -6,20 +6,68 @@
// Copyright (c) 2015年 MORITANAOKI. All rights reserved.
//
import UIKit
-class ViewController: UIViewController {
-
- override func viewDidLoad() {
- super.viewDidLoad()
- // Do any additional setup after loading the view, typically from a nib.
+struct Table {
+ let name: String
+ let keys: [String]
+ let localizations: [String]
+ init(name: String, keys: [String], localizations: [String]) {
+ self.name = name
+ self.keys = keys
+ self.localizations = localizations
}
+}
- override func didReceiveMemoryWarning() {
- super.didReceiveMemoryWarning()
- // Dispose of any resources that can be recreated.
+class ViewController: UITableViewController {
+
+ let tables = [
+ Table(
+ name: "Localizable",
+ keys: Multilingual.Localizable.keys(),
+ localizations: Multilingual.Localizable.localizations()
+ ),
+ Table(
+ name: "Animal",
+ keys: Multilingual.Animal.keys(),
+ localizations: Multilingual.Animal.localizations()
+ ),
+ Table(
+ name: "SampleSample",
+ keys: Multilingual.SampleSample.keys(),
+ localizations: Multilingual.SampleSample.localizations()
+ ),
+ Table(
+ name: "Sample2Sample_Localization",
+ keys: Multilingual.Sample2Sample_Localization.keys(),
+ localizations: Multilingual.Sample2Sample_Localization.localizations()
+ )
+ ]
+}
+
+// MARK: UITableVIewDataSource
+extension ViewController {
+ override func numberOfSectionsInTableView(tableView: UITableView) -> Int {
+ return tables.count
}
+
+ override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
+ return tables[section].keys.count
+ }
+}
-
+// MARK: UITableViewDelegate
+extension ViewController {
+ override func tableView(tableView: UITableView, titleForHeaderInSection section: Int) -> String? {
+ return tables[section].name
+ }
+
+ override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
+ let table = tables[indexPath.section]
+ let cell = tableView.dequeueReusableCellWithIdentifier("Cell") as! UITableViewCell
+ cell.textLabel?.text = table.keys[indexPath.row]
+ cell.detailTextLabel?.text = table.localizations[indexPath.row]
+ return cell
+ }
}