Skip to content

Instantly share code, notes, and snippets.

View rtking1993's full-sized avatar

Ryan King rtking1993

  • London
View GitHub Profile
@rtking1993
rtking1993 / ItemsTableViewDataSource.swift
Created March 30, 2018 13:44
Datasource methods for a UITableView
// MARK: UITableViewDataSource Methods
extension MainViewController: UITableViewDataSource {
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return items.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = UITableViewCell(style: UITableViewCellStyle.default, reuseIdentifier: "Cell")
let item = items[indexPath.row]
cell.textLabel?.text = item.item
@rtking1993
rtking1993 / ItemsPropertyObserver.swift
Created March 30, 2018 13:42
A simple example of a property observer
// MARK: Variables
var items: [Item] = [] {
didSet {
myTableView.reloadData()
}
}
@rtking1993
rtking1993 / Item.swift
Created March 30, 2018 13:37
A simple Firebase model for an item
import FirebaseDatabase
// MARK: Item
enum ItemParameters: String {
case item = "item"
}
// MARK: Item
@rtking1993
rtking1993 / CalculatorInteractorTestSnippet.swift
Created March 28, 2018 18:19
Just one function of my test class to test the logic of my calculator operations
// MARK: Frameworks
import XCTest
// MARK: CalculatorInteractorTests
class CalculatorInteractorTests: XCTestCase {
// MARK: Variables
@rtking1993
rtking1993 / CalculatorInteractorTests.swift
Created March 28, 2018 18:12
An XCTestCase class that tests the logic of calculator operations
// MARK: Frameworks
import XCTest
// MARK: CalculatorInteractorTests
class CalculatorInteractorTests: XCTestCase {
// MARK: Variables
@rtking1993
rtking1993 / PhotoSliderView.swift
Created February 12, 2018 18:49
Creating a PhotoSliderView
import UIKit
// MARK: PhotoSliderView
class PhotoSliderView: UIView {
// MARK: Outlets
@IBOutlet var contentView: UIView!
@IBOutlet var scrollView: UIScrollView!
@rtking1993
rtking1993 / TestViewController.swift
Created January 31, 2018 15:55
Instantiating a custom UIView
import UIKit
// MARK: TestViewController
class TestViewController: UIViewController {
// MARK: Outlets
@IBOutlet var testView: TestView!
@rtking1993
rtking1993 / RaceViewController.swift
Last active January 31, 2018 14:31
Animations with UIViewAnimationOptions
import UIKit
// MARK: RaceViewController
class RaceViewController: UIViewController {
// MARK: Outlets
@IBOutlet weak var raceButton: UIButton!
@IBOutlet weak var raceView: UIView!
@rtking1993
rtking1993 / ShareSheetViewController.swift
Created January 28, 2018 08:59
Implementing ShareSheet
import UIKit
class ShareSheetViewController: UIViewController {
@IBOutlet var exampleLabel: UILabel!
@IBOutlet var exampleImageView: UIImageView!
let exampleURL = URL(string: "https://ios-cookbook.com/")
override func viewDidLoad() {
@rtking1993
rtking1993 / InterpolatingMotionEffect.swift
Created January 28, 2018 08:23
UIInterpolatingMotionEffect implementation
import UIKit
class InterpolatingMotionEffect: UIViewController {
@IBOutlet var exampleView: UIImageView!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.