Skip to content

Instantly share code, notes, and snippets.

@ffittschen
Created November 25, 2017 10:32
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ffittschen/7dcfdfe183b472f59194f4ebdde60f6c to your computer and use it in GitHub Desktop.
Save ffittschen/7dcfdfe183b472f59194f4ebdde60f6c to your computer and use it in GitHub Desktop.
How to organize a swift file
// From Jared Sinclair's blog: http://blog.jaredsinclair.com/post/152672541355/how-i-organize-a-swift-file
import UIKit
import CoreData
class DetailViewController: UIViewController {
// MARK: Internal Properties
weak var delegate: DetailViewControllerDelegate?
// MARK: UIViewController Properties
override var preferredFocusEnvironments: [UIFocusEnvironment] { }
// MARK: IBOutlets
@IBOutlet private weak var textView: UITextView!
@IBOutlet private weak var resetButton: UIButton!
// MARK: Private Properties
private var item: Item!
private var persistentContainer: NSPersistentContainer!
private var networkClient: NetworkClient!
// MARK: Init / Deinit
static func make(item: Item, persistentContainer: NSPersistentContainer, networkClient: NetworkClient) -> DetailViewController { }
// MARK: Public Methods
func refreshItem() { }
// MARK: UIViewController Methods
override func viewDidLoad() { }
override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) { }
// MARK: IBActions
@IBAction private func resetButtonTapped(_ sender: UIButton) { }
// MARK: Private Methods
private func resetText() { }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment