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 <WebKit/WebKit.h> | |
@protocol PRSProgressDelegate <NSObject> | |
- (void)setNavigationTitle:(NSString *)title; | |
- (void)setProgress:(CGFloat)progress animated:(BOOL)animated; | |
- (void)setVisible:(BOOL)visible animated:(BOOL)animated; | |
@end |
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 4.0.3 | |
import Foundation | |
extension NSRange: SurrogatePairAdjustable { | |
func adjusted(for pairs: [String.SurrogatePair]) -> NSRange { | |
if pairs.isEmpty { | |
return 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
import UIKit | |
extension UIColor { | |
struct HSBA { | |
var hue: CGFloat | |
var saturation: CGFloat | |
var brightness: CGFloat | |
var alpha: CGFloat | |
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
struct List<Element>: Sequence, Collection where Element: Hashable { | |
private var contents: [[Element]] | |
init(_ sections: [[Element]] = [[]]) { | |
contents = sections | |
} | |
// MARK: - Sequence | |
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 | |
let data = """ | |
{ | |
"version": "1.0", | |
"type": "photo", | |
"width": 240, | |
"height": 160, | |
"title": "ZB8T0193", | |
"url": "http://farm4.static.flickr.com/3123/2341623661_7c99f48bbf_m.jpg", |
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 4.1 | |
protocol AnyEquatable { | |
func isEqual(to value: Any) -> Bool | |
} | |
extension AnyEquatable where Self: Equatable { | |
func isEqual(to value: Any) -> Bool { | |
guard let value = value as? Self else { | |
return false |
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 4.1 | |
/// A type-erased encodable value | |
public struct AnyEncodable { | |
public var base: Any { | |
return value.base | |
} | |
private let value: AnyEquatable | |
private let encodeValue: (Encoder, AnyEquatable) throws -> Void |
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 4.1 | |
import Foundation | |
import Sting | |
struct Account: Equatable { | |
var id: Int | |
} | |
struct Accounts { |
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 4.2 | |
public struct Endpoint: Equatable { | |
public typealias Query = Set<QueryItem> | |
public typealias Headers = [HeaderField: String] | |
public enum Method: Equatable { | |
case get | |
case post(Body) |
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 4.2 | |
public class MutableVariable<A>: Variable<A> { | |
public typealias Transform = (inout A) -> Void | |
internal typealias Mutate = (@escaping Transform) -> Void | |
override public class func threadSafe(_ initial: A) -> MutableVariable<A> { | |
return MutableVariable(initial, queue: DispatchQueue(label: "com.shawnthroop.sting.\(self)", attributes: .concurrent)) | |
} |
OlderNewer