Skip to content

Instantly share code, notes, and snippets.

View shawn-frank's full-sized avatar

Shawn Frank shawn-frank

View GitHub Profile
@shawn-frank
shawn-frank / ExampleClass.swift
Created March 14, 2021 18:03
Simplest Way to Add Stored Property to Swift Extension
// Reference and credit: https://dzone.com/articles/simplest-way-to-add-stored-property-to-swift-exten
class ExampleClass {}
fileprivate var storedProperty_FILEPRIVATE: [ObjectIdentifier:Int] = [:]
fileprivate var storedProperty_DEFAULT: Int = 0
extension ExampleClass {
var storedProperty: Int {
get {return storedProperty_FILEPRIVATE[ObjectIdentifier(self)] ?? storedProperty_DEFAULT}
set {storedProperty_FILEPRIVATE[ObjectIdentifier(self)] = newValue}
@shawn-frank
shawn-frank / UITableViewConvenience.swift
Last active March 14, 2021 18:04
Some lines of code for common customizations required for UITableView and UITableViewCell yet easy to forget
// Remove seperator lines between UITableViewCells in UITableView
// Reference: https://stackoverflow.com/questions/26653883/delete-lines-between-uitableviewcells-in-uitableview
var tableView = UITableView()
tableView.separatorStyle = .none
// Add spacing between UITableViewCell
// Reference: https://stackoverflow.com/questions/1369831/eliminate-extra-separators-below-uitableview
// Inside UITableViewCell subclass
override func layoutSubviews() {
super.layoutSubviews()