Skip to content

Instantly share code, notes, and snippets.

View dmlebron's full-sized avatar

David dmlebron

View GitHub Profile
@dmlebron
dmlebron / ServiceStub.swift
Last active June 1, 2020 18:33
Struct inside the service stub class
import Foundation
import MapKit
import Contacts
struct DummyData {
struct Location {
static let streetAddres = "269–299 Geary St"
static let city = "San Francisco"
static let subLocality = "Union Square"
static let state = "CA"
int main(void)
{
int h = get_positive_int("Height: "); // ask height and store it as i
printf("Stored: %i\n", h); //confirm value
for (int k = 1; k <= h; k++)
{
for (int i = 1; i <= (h-k); i++)
{
printf(".");
int main(void)
{
for (int i=0; i < 3; i++)
{
for (int j=0; j<=i; j++)
{
printf("#");
}
printf("\n");
}
class SecondViewController: UIViewController {
private lazy var textField: UITextField = {
let txt = UITextField()
txt.returnKeyType = .done
txt.backgroundColor = .groupTableViewBackground
txt.layer.cornerRadius = 3.0
txt.translatesAutoresizingMaskIntoConstraints = false
txt.delegate = self
class ViewController: UIViewController {
private let textLabel: UILabel = {
let label = UILabel()
label.translatesAutoresizingMaskIntoConstraints = false
label.textColor = .black
label.textAlignment = .center
label.numberOfLines = 0
label.text = "My Label"
private let textLabel: UILabel = {
let label = UILabel()
label.textColor = .black
label.textAlignment = .center
label.numberOfLines = 0
label.text = "My Label"
return label
}()
private var showButton: UIButton = {
@objc private func showViewController(sender: UIButton) {
if let secondViewController = storyboard?.instantiateViewController(withIdentifier: “secondViewController”) as? SecondViewController {
present(secondViewController, animated: true, completion: nil)
}
}
enum Animal: String {
case unknown
case dog
case cat
}
extension Optional where Wrapped == Animal {
var unwrappedOrUnknown: Animal {
switch self {
struct MyObject {
var myProperty: String?
}
extension Optional where Wrapped == MyObject {
var unwrappedOrInit: MyObject {
switch self {
case .some(let unwrapped):
return unwrapped
extension Optional where Wrapped == Bool {
var unwrappedOrFalse: Bool {
switch self {
case .some(let unwrapped):
return unwrapped
case .none:
return false
}
}