Skip to content

Commit

Permalink
separate the FillableCell protocol requirements from the BaseCell pro…
Browse files Browse the repository at this point in the history
…tocol
  • Loading branch information
AliSoftware committed Oct 10, 2015
1 parent c311eea commit 3bca744
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 13 deletions.
11 changes: 6 additions & 5 deletions Example/DipSampleApp/Cells/BaseCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,11 @@
import UIKit

protocol BaseCell {
typealias ObjectType

static var identifier: String { get }
static var nib: UINib? { get }

static func register(tableView: UITableView)
static func dequeueFromTableView(tableView: UITableView, forIndexPath indexPath: NSIndexPath) -> Self

func fillWithObject(object: ObjectType)
}

extension BaseCell where Self : UITableViewCell {
Expand All @@ -37,4 +33,9 @@ extension BaseCell where Self : UITableViewCell {
static func dequeueFromTableView(tableView: UITableView, forIndexPath indexPath: NSIndexPath) -> Self {
return tableView.dequeueReusableCellWithIdentifier(identifier, forIndexPath: indexPath) as! Self
}
}
}

protocol FillableCell: BaseCell {
typealias ObjectType
func fillWithObject(object: ObjectType)
}
4 changes: 1 addition & 3 deletions Example/DipSampleApp/Cells/PersonCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@

import UIKit

final class PersonCell : UITableViewCell, BaseCell {
typealias ObjectType = Person

final class PersonCell : UITableViewCell, FillableCell {
@IBOutlet weak var nameLabel: UILabel!
@IBOutlet weak var genderImageView: UIImageView!
@IBOutlet weak var heightLabel: UILabel!
Expand Down
4 changes: 1 addition & 3 deletions Example/DipSampleApp/Cells/StarshipCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@

import UIKit

final class StarshipCell : UITableViewCell, BaseCell {
typealias ObjectType = Starship

final class StarshipCell : UITableViewCell, FillableCell {
@IBOutlet weak var nameLabel: UILabel!
@IBOutlet weak var modelLabel: UILabel!
@IBOutlet weak var manufacturerLabel: UILabel!
Expand Down
4 changes: 2 additions & 2 deletions Example/DipSampleApp/ViewControllers/FetchableTrait.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ extension FetchableTrait {
} else {
self.objects = [object]
}
self.tableView.reloadData()
self.tableView?.reloadData()
}
}
}
Expand All @@ -46,7 +46,7 @@ extension FetchableTrait {
fetchAll() { objects in
guard batch == self.batchRequestID else { return }
self.objects = objects
self.tableView.reloadData()
self.tableView?.reloadData()
}
}
}

0 comments on commit 3bca744

Please sign in to comment.