Consider two models defined like this:
struct User {
let id: Int
let name: String
let email: String
}
// | |
// TableviewDatasource.swift | |
// | |
// Created by Phlippie Bosman on 2019/01/30. | |
// Copyright © 2019 Kalido. All rights reserved. | |
// | |
import Reusable | |
import SwiftLCS |
// Say you have a generic class with a couple of generic types, | |
// that also takes a couple of parameters in its initializer: | |
class Foo<T, U, V> { | |
init(label: String, other: Any) { | |
// ... | |
} | |
} | |
// Instantiating objects of this class in the standard way, while not unusual, |
/* | |
Given an array with optional sub-arrays, how can I flatten the array? | |
Example: | |
Given [[1, 2], nil, [3]] | |
Expect [1, 2, 3] | |
Solution: |
/* | |
In anticipation of iOS 13, I'm implementing Sign in with Apple. | |
To get started, I just made a simple VC that brings up the auth stuff, without even handling the result. | |
When running it in a simulator and completing the sign in process, the process appears to be broken: | |
- The auth controller is not dismissed | |
- `ASAuthorizationController`'s delegate method `authorizationController:didCompleteWithAuthorization` is not called | |
The code below is intended as a simple copy+paste to make problem replication easier: | |
1. Create a new XCode project |
/** | |
Leveraging Swift's type system to represent the concept of an index type with a fixed size, | |
so that iterating over all indices doesn't require a default case. | |
*/ | |
/// The abstract properties of a fixed-size index type | |
protocol ExactNumberOfIndices: CaseIterable, RawRepresentable where RawValue == Int {} | |
/// A concrete fixed-size index type with 1 element (namely 0) | |
enum _1: Int, ExactNumberOfIndices { |