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 SwiftUI | |
| struct Platform: OptionSet | |
| { | |
| let rawValue: Int | |
| static let iOS = Platform(rawValue: 1<<0) | |
| static let tvOS = Platform(rawValue: 1<<1) | |
| static let watchOS = Platform(rawValue: 1<<2) | |
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 SwiftUI | |
| struct RegularEventCell: View { | |
| let color: Color | |
| let title: String | |
| let description: String? | |
| var body: some View { |
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
| @objc protocol Refreshable | |
| { | |
| /// The refresh control | |
| var refreshControl: UIRefreshControl? { get set } | |
| /// The table view | |
| var tableView: UITableView! { get set } | |
| /// the function to call when the user pulls down to refresh | |
| @objc func handleRefresh(_ sender: Any); |
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 testHangSquareBracket() | |
| { | |
| let input = "Text [-( Text" | |
| let expectation = self.expectation(description: "Should not hang") | |
| DispatchQueue.global().async { | |
| let builder = BBCodeAttributedStringBuilder(bbcode: input) | |
| let output = builder.attributedString | |
| XCTAssertNotNil(output) |
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 UIKit | |
| extension UIImage | |
| { | |
| /// Creates an image from drawing into a context | |
| convenience init(size: CGSize, opaque: Bool = true, operations: (CGContext)->()) | |
| { | |
| UIGraphicsBeginImageContextWithOptions(size, opaque, 0) | |
| let ctx = UIGraphicsGetCurrentContext()! |
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
| public enum VanillaRequestError: Error | |
| { | |
| case unexpectedResult(String) | |
| case restfulError(NSError) | |
| } | |
| // the result from a Vanilla API request | |
| public enum VanillaRequestResult<T> | |
| { |
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 NSRegularExpression | |
| { | |
| public func substitutingMatches(in string: String, options: NSRegularExpression.MatchingOptions = [], subsituated substitution: @escaping (NSTextCheckingResult)->(String?)) -> String | |
| { | |
| let nsString = string as NSString | |
| let length = nsString.length | |
| let entireString = NSRange(location: 0, length: length) | |
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 | |
| // value types which are convertible to and from a Double raw value | |
| protocol RawValueConvertible | |
| { | |
| init(_ rawValue: Double) | |
| var rawValue: Double { get set } | |
| } | |
| func enumerateRawValues<T: RawValueConvertible>(from: T, to: T, unitDivisor: T, block: (_ value: T)->()) |
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 ~= <T>(lhs: inout T?, object: Any?) | |
| { | |
| lhs = object as? T | |
| } | |
| func ~= (lhs: inout URL?, object: Any?) | |
| { | |
| if let string = object as? String | |
| { | |
| lhs = URL(string: string) |