Skip to content

Commit

Permalink
Update examples.
Browse files Browse the repository at this point in the history
  • Loading branch information
gk-brown committed Nov 11, 2018
1 parent ff15d06 commit 67d2969
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
8 changes: 4 additions & 4 deletions Lima-iOS/LimaTest/ControlsViewController.swift
Expand Up @@ -16,10 +16,10 @@ import UIKit
import Lima

class ControlsViewController: UITableViewController {
@IBOutlet var stepper: UIStepper!
@IBOutlet var slider: UISlider!
@IBOutlet var pageControl: UIPageControl!
@IBOutlet var progressView: UIProgressView!
var stepper: UIStepper!
var slider: UISlider!
var pageControl: UIPageControl!
var progressView: UIProgressView!

struct Section {
let heading: String
Expand Down
12 changes: 5 additions & 7 deletions Lima-iOS/LimaTest/TableViewCellController.swift
Expand Up @@ -16,34 +16,32 @@ import UIKit
import Lima

class TableViewCellController: UITableViewController {
var pharmacies: [Pharmacy]!
var pharmacies: [Pharmacy]?

override func viewDidLoad() {
super.viewDidLoad()

tableView.estimatedRowHeight = 2

tableView.register(PharmacyCell.self, forCellReuseIdentifier: PharmacyCell.description())

let jsonDecoder = JSONDecoder()

guard let url = Bundle.main.url(forResource: "pharmacies", withExtension: "json"),
let data = try? Data(contentsOf: url),
let pharmacies = try? jsonDecoder.decode([Pharmacy].self, from: data) else {
let data = try? Data(contentsOf: url) else {
fatalError()
}

self.pharmacies = pharmacies
pharmacies = try? jsonDecoder.decode([Pharmacy].self, from: data)
}

override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return pharmacies.count
return pharmacies?.count ?? 0
}

override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let pharmacyCell = tableView.dequeueReusableCell(withIdentifier: PharmacyCell.description(), for: indexPath) as! PharmacyCell

pharmacyCell.pharmacy = pharmacies[indexPath.row]
pharmacyCell.pharmacy = pharmacies?[indexPath.row]

return pharmacyCell
}
Expand Down

0 comments on commit 67d2969

Please sign in to comment.