This file contains hidden or 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
func unwrap<T1, T2>(optional1: T1?, optional2: T2?) -> (T1, T2)? { | |
switch (optional1, optional2) { | |
case let (.Some(value1), .Some(value2)): | |
return (value1, value2) | |
default: | |
return nil | |
} | |
} | |
func unwrap<T1, T2, T3>(optional1: T1?, optional2: T2?, optional3: T3?) -> (T1, T2, T3)? { |
This file contains hidden or 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
// from: https://twitter.com/jaredsinclair/status/951536021459619840 | |
// typed in from the image, but not checked yet | |
class NotificationObserver { | |
private var observers: [NSObjectProtocol] = [] | |
private let queue: OperationQueue | |
init(queue: OperationQueue = .main) { | |
self.queue = queue | |
} |
This file contains hidden or 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 | |
extension Array { | |
/// move items at indices to index (insert them at index in the order of indices) | |
/// | |
/// could be useful for dragging and dropping in a table view | |
/// | |
/// - Parameters: | |
/// - indices: the indices to move |
This file contains hidden or 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
// | |
// ImageTableViewCell.swift | |
// Images | |
// | |
// Created by Bart Jacobs on 31/07/2018. | |
// Copyright © 2018 Cocoacasts. All rights reserved. | |
// | |
import UIKit |
This file contains hidden or 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
// | |
// UIView+RSKeyboardLayoutGuide.swift | |
// RSTouchUIKit | |
// | |
// Created by Daniel Jalkut on 12/23/18. | |
// | |
import UIKit | |
// Extends UIView to expose a keyboardLayoutGuide property that can be used to tie a view controller's content |
This file contains hidden or 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 EmailAddress: | |
def __init__(self, address: str, kind: str = "home"): | |
self.address = address | |
self.kind = kind | |
class Person: | |
def __init__(self, name: str, email: EmailAddress): | |
self.name = name | |
self.email = email | |
This file contains hidden or 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 Person: | |
def __init__(self, name: str, email: str): | |
self.name = name | |
self.email = email | |
def emailAddress(self): | |
return self.email |
This file contains hidden or 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
#include <string> | |
class EmailAddress { | |
public: | |
EmailAddress(std::string name, std::string kind="home"); | |
std::string address() const { return _email; } | |
std::string kind() const { return _kind; } | |
private: | |
std::string _email; |
This file contains hidden or 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 Combine | |
struct APIError: Decodable, Error { | |
let statusCode: Int | |
} | |
// publisher code based on code in Practical Combine by Donny Wals | |
extension Decodable { |
This file contains hidden or 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
// | |
// StatefulPreviewWrapper.swift | |
// Do It | |
// | |
// Created by Jim Dovey on 10/11/19. | |
// Copyright © 2019 Jim Dovey. All rights reserved. | |
// | |
import SwiftUI | |
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) |
OlderNewer