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
------------ | |
Conformances | |
------------ | |
protocol AbsoluteValuable | |
Conformances: | |
Comparable | |
IntegerLiteralConvertible | |
SignedNumberType |
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
// Public domain - https://gist.github.com/nolanw/dff7cc5d5570b030d6ba385698348b7c | |
import Foundation | |
extension URLRequest { | |
/** | |
Configures the URL request for `multipart/form-data`. The request's `httpBody` is set, and a value is set for the HTTP header field `Content-Type`. | |
- Parameter parameters: The form data to set. |
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 | |
//: Swift type-safe protocol versions of (Mutable)Copying | |
protocol SwiftCopying { | |
associatedtype NonMutableType = Self | |
func clone() -> NonMutableType | |
} | |
extension SwiftCopying where Self: NSCopying { | |
func clone() -> NonMutableType { | |
return self.copy() as! NonMutableType |
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
// UICollectionView Objective-C example | |
- (void)viewWillAppear:(BOOL)animated { | |
[super viewWillAppear:animated]; | |
NSIndexPath *selectedIndexPath = [[self.collectionView indexPathsForSelectedItems] firstObject]; | |
if (selectedIndexPath != nil) { | |
id<UIViewControllerTransitionCoordinator> coordinator = self.transitionCoordinator; | |
if (coordinator != nil) { | |
[coordinator animateAlongsideTransition:^(id<UIViewControllerTransitionCoordinatorContext> context) { |
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
// | |
// ContentView.swift | |
// TestingMoreSwiftUI | |
// | |
// Created by Chris Eidhof on 04.06.19. | |
// Copyright © 2019 Chris Eidhof. All rights reserved. | |
// | |
import SwiftUI | |
import Combine |
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
/// `ObjectBinding` used as a way to create a `Binding` from a `BindableObject`. In this case the ViewModel | |
/// complies with `BindableObject` which is then translated into a `Binding` which is what `Toggle` is expecting | |
/// NOTE: Since it's a `DynamicViewProperty`, after its value is changed, the body will be updated. | |
class ViewModel: BindableObject { | |
let didChange = PassthroughSubject<ViewModel, Never>() | |
var isEnabled = false { | |
didSet { | |
didChange.send(self) |
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
final class Loader: BindableObject { | |
let didChange = PassthroughSubject<Data?, Never>() | |
var task: URLSessionDataTask! | |
var data: Data? = nil { | |
didSet { | |
didChange.send(data) | |
} | |
} | |
init(_ url: URL) { |
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
// This file is based largely on the Runtime package - https://github.com/wickwirew/Runtime | |
extension KeyPath { | |
var fieldName: String? { | |
guard let offset = MemoryLayout<Root>.offset(of: self) else { | |
return nil | |
} | |
let typePtr = unsafeBitCast(Root.self, to: UnsafeMutableRawPointer.self) | |
let metadata = typePtr.assumingMemoryBound(to: StructMetadata.self) |
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
////===--- EitherCollection.swift - A collection of two different types -----===// | |
//// | |
//// This source file is part of the Swift.org open source project | |
//// | |
//// Copyright (c) 2014 - 2020 Apple Inc. and the Swift project authors | |
//// Licensed under Apache License v2.0 with Runtime Library Exception | |
//// | |
//// See https://swift.org/LICENSE.txt for license information | |
//// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors | |
//// |
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 | |
protocol TypedMutableCopying { | |
associatedtype ConstantVersion | |
associatedtype MutableVersion | |
var typedCopy: ConstantVersion { get } | |
var typedMutableCopy: MutableVersion { get } | |
} |
OlderNewer