This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Player { | |
let name: String | |
let highScore: Int | |
init(name: String, highScore: Int) { | |
self.name = name | |
self.highScore = highScore | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Swift 3 | |
// Simple object example | |
class Phone { | |
let name: String | |
let serialNumber: Int | |
init(name: String, serialNumber: Int) { | |
self.name = name |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Swift 3 | |
// If you'd like to use the gestureDuration outside of the scope of the button press, create some variables. | |
var gestureStartTime: TimeInterval! | |
var gestureDuration: TimeInterval! | |
// IBAction for UILongPressGestureRecognizer | |
@IBAction func recordButtonHeld(_ sender: UILongPressGestureRecognizer) { | |
switch sender.state { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
class BMSliderControl: UIControl { | |
var minimumValue: Double = 0.0 { | |
didSet { | |
updateLayerFrames() | |
} | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
import UIKit | |
@IBDesignable class BMSegmentedControl: UIControl { | |
private var labels = [UILabel]() | |
var thumbView = UIView() | |
var items: [String] = ["BEFORE", "NEITHER", "AFTER"] { | |
didSet { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
class SASwitch: UIView { | |
var backgroundView: UIView! | |
var beforeButton: UIButton! | |
var afterButton: UIButton! | |
var buttonWindow: UIView! | |
var beforeLabel: UILabel! | |
var afterLabel: UILabel! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Swift 3 | |
func setupBeaconRegions() { | |
// Use the .filterDuplicates function on an array of beacons to create a new array of only unique UUID's | |
let beaconRegions: [iBeaconItem] = iBeacons.filterDuplicates { $0.uuid == $1.uuid && $0.uuid == $1.uuid } | |
// Iterate through new array that only contains unique UUIDs and start ranging those | |
for beacon in beaconRegions { | |
startRangingBeacon(beacon) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Swift 3 | |
extension Array { | |
func filterDuplicates(includeElement: @escaping (_ lhs: Element, _ rhs: Element) -> Bool) -> [Element] { | |
var results = [Element]() | |
forEach { (element) in | |
NewerOlder