Skip to content

Instantly share code, notes, and snippets.

View mdflores's full-sized avatar
💻

Mark Dominick Flores mdflores

💻
  • Berlin, Germany
  • 11:34 (UTC +01:00)
View GitHub Profile
@mdflores
mdflores / tableViewScrollToBottom.swift
Last active January 3, 2019 05:58
Safe Scroll To Bottom in TableView using Content Height
extension UITableView {
func scrollToBottom(animated: Bool) {
let scrollPoint = CGPoint(x: 0, y: self.contentSize.height - self.frame.size.height)
self.setContentOffset(scrollPoint, animated: animated)
}
}
@mdflores
mdflores / RevokableTask.swift
Last active April 2, 2018 12:08
RevokableTask adds a task delayed to the main queue which can be revoked or cancelled.
typealias TaskHandler = () -> ()
class RevokableTask {
private(set) var isCancelled: Bool = false
private(set) var task: TaskHandler
private(set) var delayTime: DispatchTime
private(set) var identifier: String
init(delayInSeconds: Double, task: @escaping TaskHandler) {
self.task = task