Instruction stringlengths 14 778 | input_code stringlengths 0 4.24k | output_code stringlengths 1 5.44k |
|---|---|---|
Comment failing test(template test code) | // https://github.com/Quick/Quick
import Quick
import Nimble
import RGInnerBadgeButton
class TableOfContentsSpec: QuickSpec {
override func spec() {
describe("these will fail") {
it("can do maths") {
expect(1) == 2
}
it("can read") {
ex... | // https://github.com/Quick/Quick
import Quick
import Nimble
import RGInnerBadgeButton
class TableOfContentsSpec: QuickSpec {
override func spec() {
// describe("these will fail") {
//
// it("can do maths") {
// expect(1) == 2
// }
//
// it("can read") {
// ... |
Add json and protobuf api for swift | import Kitura
import HeliumLogger
import SwiftProtobuf
HeliumLogger.use()
let router = Router()
func getLibrary() -> MyLibrary {
let map = ["route": "66"]
var bookInfo = BookInfo()
bookInfo.id = 10
bookInfo.title = "Welcome to Swift"
bookInfo.author = "Apple Inc."
var library = MyLi... | import Kitura
import HeliumLogger
import SwiftProtobuf
HeliumLogger.use()
let router = Router()
func getLibrary() -> MyLibrary {
let map = ["route": "66"]
var bookInfo = BookInfo()
bookInfo.id = 10
bookInfo.title = "Welcome to Swift"
bookInfo.author = "Apple Inc."
var library = MyLi... |
Update ConfigExample to Swift 4.2 | //
// Copyright (c) 2016 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agre... | //
// Copyright (c) 2016 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agre... |
Add sendJSON funcs to canvas model | //
// Canvas.swift
// place
//
// Created by Valtteri Koskivuori on 18/06/2017.
//
//
import Vapor
class Canvas {
//Connection is a key-val pair; userID:WebSocket
//Consider making User hashable somehow? And have User:WebSocket keyval pairs
var connections: [String: WebSocket]
func updateTileToClients() {
... | //
// Canvas.swift
// place
//
// Created by Valtteri Koskivuori on 18/06/2017.
//
//
import Vapor
class Canvas {
//Connection is a key-val pair; userID:WebSocket
//Consider making User hashable somehow? And have User:WebSocket keyval pairs
var connections: [String: WebSocket]
func updateTileToClients() {
... |
Add newline at end of file. | //
// FakeProfileHeaderCellSizeCalculator.swift
// Ello
//
// Created by Ryan Boyajian on 3/24/15.
// Copyright (c) 2015 Ello. All rights reserved.
//
import Foundation
class FakeProfileHeaderCellSizeCalculator: ProfileHeaderCellSizeCalculator {
override func processCells(cellItems:[StreamCellItem], completi... | //
// FakeProfileHeaderCellSizeCalculator.swift
// Ello
//
// Created by Ryan Boyajian on 3/24/15.
// Copyright (c) 2015 Ello. All rights reserved.
//
import Foundation
class FakeProfileHeaderCellSizeCalculator: ProfileHeaderCellSizeCalculator {
override func processCells(cellItems:[StreamCellItem], completi... |
Optimize deck shuffling in Swift | public struct Card: CustomStringConvertible {
public enum Suit: Int {
case Spade = 0
case Club
case Heart
case Diamond
}
public enum FaceValue: Int {
case Ace = 1
case Two = 2
case Three = 3
case Four = 4
case Five = 5
case Six ... | import Foundation
public struct Card: CustomStringConvertible {
public enum Suit: Int {
case Spade = 0
case Club
case Heart
case Diamond
}
public enum FaceValue: Int {
case Ace = 1
case Two = 2
case Three = 3
case Four = 4
case Five = ... |
Use setup in test to init models | import XCTest
import CoreLocation
@testable import columbus
final class UTMCreateLocationDelegate:XCTestCase
{
private let kAccuracy:CLLocationAccuracy = kCLLocationAccuracyBestForNavigation
//MARK: tests
func testAskAuthorization()
{
let model:MCreateLocationDelegate = MCreateLocatio... | import XCTest
import CoreLocation
@testable import columbus
final class UTMCreateLocationDelegate:XCTestCase
{
private var modelLocation:MCreateLocationDelegate?
private var modelCreate:MCreate?
private let kAccuracy:CLLocationAccuracy = kCLLocationAccuracyBestForNavigation
override func setUp()
... |
Update the test for modernization of QuartzCore APIs | // RUN: %target-run-simple-swift | FileCheck %s
// REQUIRES: OS=macosx
// FIXME: iOS doesn't have CIVector?
import QuartzCore
// Do NOT add anything that publicly imports Foundation here!
var v = CIVector(x:7);
// CHECK: x = 7
println("x = \(v.X())");
| // RUN: %target-run-simple-swift | FileCheck %s
// REQUIRES: OS=macosx
// FIXME: iOS doesn't have CIVector?
import QuartzCore
// Do NOT add anything that publicly imports Foundation here!
var v = CIVector(x:7);
// CHECK: x = 7
println("x = \(v.X)")
|
Fix temporarily a test case | //
// BasicStringTest.swift
// MochaUtilities
//
// Created by Gregory Sholl e Santos on 09/06/17.
// Copyright © 2017 CocoaPods. All rights reserved.
//
import XCTest
@testable import MochaUtilities
class BasicStringTest: XCTestCase {
override func setUp() {
super.setUp()
}
override... | //
// BasicStringTest.swift
// MochaUtilities
//
// Created by Gregory Sholl e Santos on 09/06/17.
// Copyright © 2017 CocoaPods. All rights reserved.
//
import XCTest
@testable import MochaUtilities
class BasicStringTest: XCTestCase {
override func setUp() {
super.setUp()
}
override... |
Use faker in detail view | import Foundation
import Wall
class DetailViewController: WallController {
override func viewDidLoad() {
super.viewDidLoad()
title = post!.text
let delayTime = dispatch_time(DISPATCH_TIME_NOW,
Int64(0.1 * Double(NSEC_PER_SEC)))
dispatch_after(delayTime, dispatch_get_main_queue()) {
sel... | import Foundation
import Wall
import Faker
class DetailViewController: WallController {
let faker = Faker()
override func viewDidLoad() {
super.viewDidLoad()
title = post!.text
let delayTime = dispatch_time(DISPATCH_TIME_NOW,
Int64(0.1 * Double(NSEC_PER_SEC)))
dispatch_after(delayTime, di... |
Add NSDate -> String transformation | //
// ServerDateFormatter.swift
// Ello
//
// Created by Sean Dougherty on 12/3/14.
// Copyright (c) 2014 Ello. All rights reserved.
//
import Foundation
let ServerDateFormatter = NSDateFormatter()
public extension NSString {
func toNSDate() -> NSDate? {
ServerDateFormatter.dateFormat = "yyyy-MM-dd'... | //
// ServerDateFormatter.swift
// Ello
//
// Created by Sean Dougherty on 12/3/14.
// Copyright (c) 2014 Ello. All rights reserved.
//
import Foundation
let ServerDateFormatter: NSDateFormatter = {
let formatter = NSDateFormatter()
formatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"
formatter.timeZ... |
Remove padding from 'Load more comments' cells | //
// MoreCommentCellView.swift
// Breadit
//
// Created by William Hester on 4/30/16.
// Copyright © 2016 William Hester. All rights reserved.
//
import UIKit
class MoreCommentCellView: CommentCellView {
override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
super.init(style: style, ... | //
// MoreCommentCellView.swift
// Breadit
//
// Created by William Hester on 4/30/16.
// Copyright © 2016 William Hester. All rights reserved.
//
import UIKit
class MoreCommentCellView: CommentCellView {
override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
super.init(style: style, ... |
Make `SECCommonGraphicStyle` conform to `SECEnumable` an `SECMappable` | //
// SECGraphicStyle.swift
// SwiftyEcharts
//
// Created by Pluto Y on 11/02/2017.
// Copyright © 2017 com.pluto-y. All rights reserved.
//
public protocol SECGraphicStyle : SECShadowable {
var fill: SECColor? { get set }
var stroke: SECColor? { get set }
var lineWidth: Float? { get set }
}
public s... | //
// SECGraphicStyle.swift
// SwiftyEcharts
//
// Created by Pluto Y on 11/02/2017.
// Copyright © 2017 com.pluto-y. All rights reserved.
//
public protocol SECGraphicStyle : SECShadowable {
var fill: SECColor? { get set }
var stroke: SECColor? { get set }
var lineWidth: Float? { get set }
}
public s... |
Add a Church-encoded `true` value. | // Copyright © 2015 Rob Rix. All rights reserved.
extension Module {
public static var churchBoolean: Module {
let Boolean = Declaration("Boolean",
type: .Type,
value: Recur.lambda(.Type) { Recur.lambda($0, $0, const($0)) })
return Module([ Boolean ])
}
}
import Prelude
| // Copyright © 2015 Rob Rix. All rights reserved.
extension Module {
public static var churchBoolean: Module {
let Boolean = Declaration("Boolean",
type: .Type,
value: Recur.lambda(.Type) { Recur.lambda($0, $0, const($0)) })
let `true` = Declaration("true",
type: Boolean.ref,
value: Recur.lambda(.Ty... |
Use config instead of loading everything out of the config dictionary | //
// Dependencies.swift
// Whitelabel
//
// Created by Martin Eberl on 27.02.17.
// Copyright © 2017 Martin Eberl. All rights reserved.
//
import Foundation
class Dependencies {
static let shared = Dependencies()
let loader: ContentLoader?
let locationProvider: LocationProvider?
let timeStor... | //
// Dependencies.swift
// Whitelabel
//
// Created by Martin Eberl on 27.02.17.
// Copyright © 2017 Martin Eberl. All rights reserved.
//
import Foundation
class Dependencies {
static let shared = Dependencies()
let loader: ContentLoader?
let locationProvider: LocationProvider?
let timeStor... |
Fix whitespace in a test | // RUN: %target-swift-frontend %s -emit-ir -o -
func f() {
enum NotAnError: Swift.Error {
case nope(length: Int)
}
}
| // RUN: %target-swift-frontend %s -emit-ir -o -
func f() {
enum NotAnError: Swift.Error {
case nope(length: Int)
}
}
|
Stop checking for quit players' ready states | //
// WKRReadyStates.swift
// WKRKit
//
// Created by Andrew Finke on 8/31/17.
// Copyright © 2017 Andrew Finke. All rights reserved.
//
import Foundation
public struct WKRReadyStates: Codable {
let players: [WKRPlayer]
init(players: [WKRPlayer]) {
self.players = players
}
public func isP... | //
// WKRReadyStates.swift
// WKRKit
//
// Created by Andrew Finke on 8/31/17.
// Copyright © 2017 Andrew Finke. All rights reserved.
//
import Foundation
public struct WKRReadyStates: Codable {
let players: [WKRPlayer]
init(players: [WKRPlayer]) {
self.players = players
}
public func isP... |
Simplify type-erasure by making it just a function | //
// Property.swift
// R.swift
//
// Created by Mathijs Kadijk on 05-01-16.
// Copyright © 2016 Mathijs Kadijk. All rights reserved.
//
import Foundation
protocol Property: UsedTypesProvider, CustomStringConvertible {
var name: String { get }
}
extension Property {
var callName: String {
return sanitize... | //
// Property.swift
// R.swift
//
// Created by Mathijs Kadijk on 05-01-16.
// Copyright © 2016 Mathijs Kadijk. All rights reserved.
//
import Foundation
protocol Property: UsedTypesProvider, CustomStringConvertible {
var name: String { get }
}
extension Property {
var callName: String {
return sanitize... |
Add a random number to more filter awesomeness | //
// FilterHelper.swift
// CETAVFilter
//
// Created by Chris Jimenez on 2/14/16.
// Copyright © 2016 Chris Jimenez. All rights reserved.
//
import Foundation
import UIKit
/// A helper class to apply filters to an image
public class FilterHelper {
//The context that will help us creating the image
l... | //
// FilterHelper.swift
// CETAVFilter
//
// Created by Chris Jimenez on 2/14/16.
// Copyright © 2016 Chris Jimenez. All rights reserved.
//
import Foundation
import UIKit
/// A helper class to apply filters to an image
public class FilterHelper {
//The context that will help us creating the image
l... |
Check if dragged file has movie ext | //
// MovieDraggable.swift
// Subtle
//
// Created by Miguel Molina on 03/02/16.
// Copyright © 2016 Miguel Molina. All rights reserved.
//
import Cocoa
protocol FileQueueDelegate {
func queueFile(path: String)
}
class MovieDraggable: NSView {
var delegate: FileQueueDelegate?
required init(coder: N... | //
// MovieDraggable.swift
// Subtle
//
// Created by Miguel Molina on 03/02/16.
// Copyright © 2016 Miguel Molina. All rights reserved.
//
import Cocoa
protocol FileQueueDelegate {
func queueFile(path: String)
}
let movieExtensions = ["mov", "avi", "mkv", "mp4"]
private func isMovie(path: String) -> Bool {... |
Fix a unit test for CustomStringConvertible conformance for string representation of Container in Swift 3. | //
// Container+SwinjectStoryboardSpec.swift
// Swinject
//
// Created by Yoichi Tagaya on 2/27/16.
// Copyright © 2016 Swinject Contributors. All rights reserved.
//
import Quick
import Nimble
import Swinject
#if os(iOS) || os(OSX) || os(tvOS)
class Container_SwinjectStoryboardSpec: QuickSpec {
override func... | //
// Container+SwinjectStoryboardSpec.swift
// Swinject
//
// Created by Yoichi Tagaya on 2/27/16.
// Copyright © 2016 Swinject Contributors. All rights reserved.
//
import Quick
import Nimble
import Swinject
#if os(iOS) || os(OSX) || os(tvOS)
class Container_SwinjectStoryboardSpec: QuickSpec {
override func... |
Add equatable conformance to Environment | enum Environment {
case Production, Development, custom(String)
var string: String {
switch self {
case .Production:
return "Production"
case .Development:
return "Development"
case .custom(let string):
return string
}
}
}
// loo... | enum Environment {
case Production, Development, custom(String)
var string: String {
switch self {
case .Production:
return "Production"
case .Development:
return "Development"
case .custom(let string):
return string
}
}
}
extens... |
Add struct for dealing with broker connection | //
// Broker.swift
// SwiftKafka
//
// Created by Athanasios Theodoridis on 26/08/2017.
//
//
/// An enum representing the protocol used for a broker connection
public enum BrokerProtocol: String {
case plaintext = "PLAINTEXT://"
case ssl = "SSL://"
case sasl = "SASL://"
case sasl_plaintext = "... | //
// Broker.swift
// SwiftKafka
//
// Created by Athanasios Theodoridis on 26/08/2017.
//
//
/// An enum representing the protocol used for a broker connection
public enum BrokerProtocol: String {
case plaintext = "PLAINTEXT://"
case ssl = "SSL://"
case sasl = "SASL://"
... |
Fix Doc for CGFloat Central | //
// CEMKit+CGFloat.swift
//
//
// Created by Cem Olcay on 12/08/15.
//
//
import UIKit
extension CGFloat {
/// EZSwiftExtensions
public var center: CGFloat { return (self / 2) }
}
/// EZSE: Converts angle degrees to radians
public func degreesToRadians (angle: CGFloat) -> CGFloat {
return (CGFloat (M... | //
// CEMKit+CGFloat.swift
//
//
// Created by Cem Olcay on 12/08/15.
//
//
import UIKit
extension CGFloat {
/// EZSE: Return the central value of CGFloat.
public var center: CGFloat { return (self / 2) }
}
/// EZSE: Converts angle degrees to radians.
public func degreesToRadians (angle: CGFloat) -> CGFloa... |
Add moveToPath(_:) method to File | //
// FileKit.swift
// FileKit
//
// Created by Nikolai Vazquez on 9/1/15.
// Copyright © 2015 Nikolai Vazquez. All rights reserved.
//
import Foundation
public class File: StringLiteralConvertible {
// MARK: - File
public var path: Path
public init(path: Path) {
self.path = pat... | //
// FileKit.swift
// FileKit
//
// Created by Nikolai Vazquez on 9/1/15.
// Copyright © 2015 Nikolai Vazquez. All rights reserved.
//
import Foundation
public class File: StringLiteralConvertible {
// MARK: - File
public var path: Path
public init(path: Path) {
self.path = pat... |
Add search bar to navigation bar | import UIKit
class ControllerList:UIViewController
{
init()
{
super.init(nibName:nil, bundle:nil)
}
required init?(coder:NSCoder)
{
return nil
}
override func loadView()
{
let view:ViewList = ViewList(controller:self)
self.view = view
}
}
| import UIKit
class ControllerList:UIViewController
{
init()
{
super.init(nibName:nil, bundle:nil)
navigationItem.titleView = ViewListBar()
}
required init?(coder:NSCoder)
{
return nil
}
override func loadView()
{
let view:ViewList = ViewList(con... |
Use data phase as enum | import Foundation
struct MVitaPtpDataPhase
{
static let none:UInt32 = 0
static let send:UInt32 = 1
static let receive:UInt32 = 2
}
| import Foundation
enum MVitaPtpDataPhase:UInt32
{
case none = 0
case send = 1
case receive = 2
}
|
Mark another StdlibUnittest as "XFAIL: interpret". | // RUN: %target-run-simple-swift
import Foundation
import StdlibUnittest
var FoundationPrinting = TestSuite("FoundationPrinting")
FoundationPrinting.test("OverlayTypesHaveDescription") {
func hasDescription(_: Printable) {}
var a: ObjCBool = true
hasDescription(a)
}
FoundationPrinting.test("ObjCBoolPrinting"... | // RUN: %target-run-simple-swift
// XFAIL: interpret
import Foundation
import StdlibUnittest
var FoundationPrinting = TestSuite("FoundationPrinting")
FoundationPrinting.test("OverlayTypesHaveDescription") {
func hasDescription(_: Printable) {}
var a: ObjCBool = true
hasDescription(a)
}
FoundationPrinting.tes... |
Correct typo and add clockwise direction | //
// GTProgressBarDirection.swift
// GTProgressBar
//
// Created by greg on 15/11/2017.
//
import Foundation
public enum GTProgressBarDirection: Int {
case anticlocwise
}
| //
// GTProgressBarDirection.swift
// GTProgressBar
//
// Created by greg on 15/11/2017.
//
import Foundation
public enum GTProgressBarDirection: Int {
case clockwise
case anticlockwise
}
|
Use swift tools version 5 | // swift-tools-version:4.2
import PackageDescription
let package = Package(
name: "Clang",
products: [
.library(
name: "Clang",
targets: ["Clang"])
],
dependencies: [ ],
targets: [
.systemLibrary(
name: "cclang",
pkgConfig: "cclang",
providers: [
... | // swift-tools-version:5.0
import PackageDescription
let package = Package(
name: "Clang",
products: [
.library(
name: "Clang",
targets: ["Clang"])
],
dependencies: [ ],
targets: [
.systemLibrary(
name: "cclang",
pkgConfig: "cclang",
providers: [
... |
Change getting started to bullet points. | import Prelude
/*:
# Prelude
A collection of tools that are used in the Kickstarter apps.
---
## Getting started
To execute these playground files you must first open `Prelude.xcworkspace` instead of the playground file directly,
and hit `cmd+B` in order to build the framework. To render the markdown go to Editor ... | import Prelude
/*:
# Prelude
A collection of tools that are used in the Kickstarter apps.
---
## Getting started
* Open `Prelude.xcworkspace` instead of the playground file directly.
* Build the `Prelude` framework (`cmd+B`).
* Render the markdown by going to Editor > Show Rendered Markup.
## Table of contents
*... |
Test the iteration of effectful streams. | // Copyright (c) 2014 Rob Rix. All rights reserved.
import Traversal
import XCTest
class StreamTests: XCTestCase {
func testStreams() {
let sequence = [1, 2, 3, 4, 5, 6, 7, 8, 9]
let reducible = ReducibleOf(sequence: sequence)
let stream = Stream(reducible)
XCTAssertEqual(first(stream)!, 1)
XCTAssertEqua... | // Copyright (c) 2014 Rob Rix. All rights reserved.
import Traversal
import XCTest
class StreamTests: XCTestCase {
func testStreams() {
let sequence = [1, 2, 3, 4, 5, 6, 7, 8, 9]
let reducible = ReducibleOf(sequence: sequence)
let stream = Stream(reducible)
XCTAssertEqual(first(stream)!, 1)
XCTAssertEqua... |
Revert "Make subscribe handler argument anonymous" | import Foundation
public struct SubscriptionOptions: OptionSetType {
public let rawValue: Int
public init(rawValue: Int) { self.rawValue = rawValue }
public static let New = SubscriptionOptions(rawValue: 1)
public static let Initial = SubscriptionOptions(rawValue: 2)
}
public struct Observable<T> {
... | import Foundation
public struct SubscriptionOptions: OptionSetType {
public let rawValue: Int
public init(rawValue: Int) { self.rawValue = rawValue }
public static let New = SubscriptionOptions(rawValue: 1)
public static let Initial = SubscriptionOptions(rawValue: 2)
}
public struct Observable<T> {
... |
Add some tests for malformed availability attributes. | // RUN: %swift %s -parse -verify
@availability(*, unavailable)
func unavailable_func() {}
@availability(*, unavailable, message="message")
func unavailable_func_with_message() {}
@availability(iOS, unavailable)
@availability(OSX, unavailable)
func unavailable_multiple_platforms() {}
@availability(badPlatform, unava... | // RUN: %swift %s -parse -verify
@availability(*, unavailable)
func unavailable_func() {}
@availability(*, unavailable, message="message")
func unavailable_func_with_message() {}
@availability(iOS, unavailable)
@availability(OSX, unavailable)
func unavailable_multiple_platforms() {}
@availability // expected-error ... |
Add wildcard parameter case to VariableType test | func x(_ param: Int) -> Int {
param
}
let y: (String) -> Void = { param in }
let z = { (param: String) in
param.count
}
// RUN: %sourcekitd-test -req=collect-var-type %s -- %s | %FileCheck %s
// CHECK: (1:10, 1:15): Int (explicit type: 1)
// CHECK: (5:5, 5:6): (String) -> Void (explicit type: 1)
// CHECK: (5:29,... | func x(_ param: Int) -> Int {
param
}
let y: (String) -> Void = { param in }
let z = { (param: String) in
param.count
}
let w: (String, Int) -> Void = { (_, x) in }
// RUN: %sourcekitd-test -req=collect-var-type %s -- %s | %FileCheck %s
// CHECK: (1:10, 1:15): Int (explicit type: 1)
// CHECK: (5:5, 5:6): (Strin... |
Add static shorthands for left, right, up and down 2D vectors |
import Darwin
struct Vector2D {
let x: Double
let y: Double
init(_ x: Double, _ y: Double) {
self.x = x
self.y = y
}
var magnitude: Double {
return sqrt(x * x + y * y)
}
}
|
import Darwin
struct Vector2D {
let x: Double
let y: Double
init(_ x: Double, _ y: Double) {
self.x = x
self.y = y
}
var magnitude: Double {
return sqrt(x * x + y * y)
}
static let left = Vector2D(-1, 0)
static let right = Vector2D(1, 0)
stati... |
Remove empty UI test to save build time | //
// Rocket_ChatUITests.swift
// Rocket.ChatUITests
//
// Created by Rafael K. Streit on 7/5/16.
// Copyright © 2016 Rocket.Chat. All rights reserved.
//
import XCTest
class RocketChatUITests: XCTestCase {
override func setUp() {
super.setUp()
// Put setup code here. This method is called b... | //
// Rocket_ChatUITests.swift
// Rocket.ChatUITests
//
// Created by Rafael K. Streit on 7/5/16.
// Copyright © 2016 Rocket.Chat. All rights reserved.
//
import XCTest
class RocketChatUITests: XCTestCase {
}
|
Add test cases for `GraphSerie.Circular` | //
// GraphSerieSpec.swift
// SwiftyEcharts
//
// Created by Pluto Y on 26/10/2017.
// Copyright © 2017 com.pluto-y. All rights reserved.
//
import Quick
import Nimble
@testable import SwiftyEcharts
class GraphSerieSpec: QuickSpec {
override func spec() {
describe("For GraphSerie.Layout") {
... | //
// GraphSerieSpec.swift
// SwiftyEcharts
//
// Created by Pluto Y on 26/10/2017.
// Copyright © 2017 com.pluto-y. All rights reserved.
//
import Quick
import Nimble
@testable import SwiftyEcharts
class GraphSerieSpec: QuickSpec {
override func spec() {
describe("For GraphSerie.Layout") {
... |
Test factory url and request | import XCTest
class TMGiphyRandom:XCTestCase
{
}
| import XCTest
@testable import gattaca
class TMGiphyRandom:XCTestCase
{
//MARK: internal
func testFactoryUrl()
{
let url:URL? = MGiphy.factoryRandomUrl()
XCTAssertNotNil(
url,
"failed factorying url")
}
func testFactoryRequest()
{
... |
Fix releasing the object too fast | import Foundation
import XCTest
// NOTE: This file is not intended to be included in the Xcode project or CocoaPods.
// It is picked up by the Swift Package Manager during its build process.
#if SWIFT_PACKAGE
open class QuickConfiguration: NSObject {
open class func configure(_ configuration: Configuration... | import Foundation
import XCTest
// NOTE: This file is not intended to be included in the Xcode project or CocoaPods.
// It is picked up by the Swift Package Manager during its build process.
#if SWIFT_PACKAGE
open class QuickConfiguration: NSObject {
open class func configure(_ configuration: Configuration... |
Use NS_BLOCK_ASSERTIONS for SwiftPM release builds | // swift-tools-version:5.1
import PackageDescription
let package = Package(
name: "TrustKit",
platforms: [
.iOS(.v12),
.macOS(.v10_13),
.tvOS(.v12),
.watchOS(.v4)
],
products: [
.library(
name: "TrustKit",
targets: ["TrustKit"]
),
... | // swift-tools-version:5.1
import PackageDescription
let package = Package(
name: "TrustKit",
platforms: [
.iOS(.v12),
.macOS(.v10_13),
.tvOS(.v12),
.watchOS(.v4)
],
products: [
.library(
name: "TrustKit",
targets: ["TrustKit"]
),
... |
Stop using internal/external name as property name overrides it and prevents the code from working. Make components a var so that it can be modified (isn't it a reference type?). | //
// NSURL+HTTP.swift
// ModestProposal
//
// Copyright (c) 2014 Justin Kolb - http://franticapparatus.net
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, includin... | //
// NSURL+HTTP.swift
// ModestProposal
//
// Copyright (c) 2014 Justin Kolb - http://franticapparatus.net
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, includin... |
Send editingChanged when using UITextField setClearButton | //
// Created by Tom Baranes on 18/01/2017.
// Copyright © 2017 Tom Baranes. All rights reserved.
//
import UIKit
public extension UITextField {
public func setClearButton(with image: UIImage) {
let clearButton = UIButton(type: .custom)
clearButton.setImage(image, for: .normal)
clearBut... | //
// Created by Tom Baranes on 18/01/2017.
// Copyright © 2017 Tom Baranes. All rights reserved.
//
import UIKit
public extension UITextField {
public func setClearButton(with image: UIImage) {
let clearButton = UIButton(type: .custom)
clearButton.setImage(image, for: .normal)
clearBut... |
Disable cache for DELETE request | //
// S3+Delete.swift
// S3
//
// Created by Ondrej Rafaj on 11/05/2018.
//
import Foundation
import Vapor
// Helper S3 extension for deleting files by their URL/path
public extension S3 {
// MARK: Delete
/// Delete file from S3
public func delete(file: LocationConvertible, headers: [String:... | //
// S3+Delete.swift
// S3
//
// Created by Ondrej Rafaj on 11/05/2018.
//
import Foundation
import Vapor
// Helper S3 extension for deleting files by their URL/path
public extension S3 {
// MARK: Delete
/// Delete file from S3
public func delete(file: LocationConvertible, headers: [String:... |
Support both versions of Swift | import Foundation
import AutobahnDescription
// let autobahn = Autobahn()
// autoban.defaultTask = "release"
beforeAll { highway in
print("Driving highway: \(highway)")
}
highway("build") {
print("Building...")
try sh("swift", "build")
}
highway("test") {
try sh("swift", "test")
}
highway("deploy") {
print("... | import Foundation
import AutobahnDescription
// let autobahn = Autobahn()
// autoban.defaultTask = "release"
beforeAll { highway in
print("Driving highway: \(highway)")
}
highway("build") {
print("Building...")
try sh("swift", "build")
}
highway("test") {
try sh("swift", "test")
}
highway("deploy") {
print("... |
Update UIApplicationLaunchOptionsKey to UIApplication.LaunchOptionsKey for xcode10 | /*
* Copyright 2015-present Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License. You may obtain
* a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or... | /*
* Copyright 2015-present Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License. You may obtain
* a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or... |
Add public initializer to error middleware | //
// JsonApiErrorMiddleware.swift
// VaporJsonApi
//
// Created by Koray Koska on 01/05/2017.
//
//
import Vapor
import HTTP
public final class JsonApiErrorMiddleware: Middleware {
public func respond(to request: Request, chainingTo next: Responder) throws -> Response {
do {
return try ne... | //
// JsonApiErrorMiddleware.swift
// VaporJsonApi
//
// Created by Koray Koska on 01/05/2017.
//
//
import Vapor
import HTTP
public final class JsonApiErrorMiddleware: Middleware {
public init() {}
public func respond(to request: Request, chainingTo next: Responder) throws -> Response {
do {
... |
Update to match the new array syntax | // Playground - noun: a place where people can play
import Cocoa
class Person {
var name: String
var age: Int?
var consideredDangerous = false
init(name: String, age: Int?) {
self.name = name
self.age = age
}
convenience init(name: String) {
self.init(name: name, age: nil)
}
}
enum... | // Playground - noun: a place where people can play
import Cocoa
class Person {
var name: String
var age: Int?
var consideredDangerous = false
init(name: String, age: Int?) {
self.name = name
self.age = age
}
convenience init(name: String) {
self.init(name: name, age: nil)
}
}
enum... |
Change parameter type of updateProfile: [String:String] to | //
// ProfileAPI.swift
// FeedlyKit
//
// Created by Hiroki Kumamoto on 1/20/15.
// Copyright (c) 2015 Hiroki Kumamoto. All rights reserved.
//
import Alamofire
import SwiftyJSON
extension CloudAPIClient {
/**
Get the profile of the user
GET /v3/profile
*/
public func fetchProfile(comp... | //
// ProfileAPI.swift
// FeedlyKit
//
// Created by Hiroki Kumamoto on 1/20/15.
// Copyright (c) 2015 Hiroki Kumamoto. All rights reserved.
//
import Alamofire
import SwiftyJSON
extension CloudAPIClient {
/**
Get the profile of the user
GET /v3/profile
*/
public func fetchProfile(comp... |
Change struct with static funcs to enum | //
// StatusBar.swift
// Freetime
//
// Created by Ryan Nystrom on 5/17/17.
// Copyright © 2017 Ryan Nystrom. All rights reserved.
//
import Foundation
import JDStatusBarNotification
struct StatusBar {
private static func provideHapticFeedback() {
UINotificationFeedbackGenerator().notificationOcc... | //
// StatusBar.swift
// Freetime
//
// Created by Ryan Nystrom on 5/17/17.
// Copyright © 2017 Ryan Nystrom. All rights reserved.
//
import Foundation
import JDStatusBarNotification
enum StatusBar {
private static func provideHapticFeedback() {
UINotificationFeedbackGenerator().notificationOccur... |
Use default (empty) edge sets. | // Copyright (c) 2015 Rob Rix. All rights reserved.
final class InferenceTests: XCTestCase {
func testGraphsWithoutReturnsHaveUnitType() {
assert(type(Graph()), ==, .Unit)
}
func testGraphsWithOneReturnHaveVariableType() {
assert(type(Graph(nodes: [Identifier(): .Return((0, .Unit))])), ==, 0)
}
func testGr... | // Copyright (c) 2015 Rob Rix. All rights reserved.
final class InferenceTests: XCTestCase {
func testGraphsWithoutReturnsHaveUnitType() {
assert(type(Graph()), ==, .Unit)
}
func testGraphsWithOneReturnHaveVariableType() {
assert(type(Graph(nodes: [Identifier(): .Return((0, .Unit))])), ==, 0)
}
func testGr... |
Revert "[Identity] Require non blur image even if we find a barcode" | //
// DocumentScannerOutput.swift
// StripeIdentity
//
// Created by Mel Ludowise on 3/1/22.
//
import Foundation
@_spi(STP) import StripeCameraCore
/**
Consolidated output from all ML models / detectors that make up document
scanning. The combination of this output will determine if the image captured
is high ... | //
// DocumentScannerOutput.swift
// StripeIdentity
//
// Created by Mel Ludowise on 3/1/22.
//
import Foundation
@_spi(STP) import StripeCameraCore
/**
Consolidated output from all ML models / detectors that make up document
scanning. The combination of this output will determine if the image captured
is high ... |
Add additional Roostfile parsing test | import Speedy
import Nimble
class RoostfileSpec: Spec {
var definition: String {
get {
return "\n".join([
"name: Test",
"version: 0.1.2",
"target_type: executable",
])
}
}
func spec() {
describe("when parsing") {
it("should parse basic properties") {
... | import Speedy
import Nimble
class RoostfileSpec: Spec {
var definition: String {
get {
return "\n".join([
"name: Test",
"version: 0.1.2",
"target_type: executable",
"sources:",
" - TestFile.swift",
" - TestDirectory/",
])
}
}
func spec() {
... |
Interpolate with a temporary variable. | // Copyright (c) 2015 Rob Rix. All rights reserved.
public func export<T>(graph: Graph<T>) -> String {
return
"digraph tesseract {\n"
+ join("", lazy(graph.edges).map { "\t" + $0.source.identifier.description + " -> " + $0.destination.identifier.description + ";\n" })
+ "}"
}
// MARK: - Imports
import Prelude... | // Copyright (c) 2015 Rob Rix. All rights reserved.
public func export<T>(graph: Graph<T>) -> String {
let edges = join("\n", lazy(graph.edges).map { "\t" + $0.source.identifier.description + " -> " + $0.destination.identifier.description + ";" })
return "digraph tesseract {\n\(edges)\n}"
}
// MARK: - Imports
im... |
Switch to my own branch of Promise library fix a fix | // swift-tools-version:4.0
// The swift-tools-version declares the minimum version of Swift required to build this package.
import PackageDescription
let package = Package(
name: "RequestBuilder",
products: [
// Products define the executables and libraries produced by a package, and make them visible... | // swift-tools-version:4.0
// The swift-tools-version declares the minimum version of Swift required to build this package.
import PackageDescription
let package = Package(
name: "RequestBuilder",
products: [
// Products define the executables and libraries produced by a package, and make them visible... |
Update 285 for combined engine/server | // Regression test for optimizations that might incorrectly execute function
// on wrong process
@dispatch=WORKER
(int o) worker_task (int i) "turbine" "0.0.1" [
"set <<o>> <<i>>; if { $turbine::mode != \"WORKER\" } { error $turbine::mode }"
];
@dispatch=CONTROL
(int o) control_task (int i) "turbine" "0.0.1" [
"s... | // Regression test for optimizations that might incorrectly execute function
// on wrong process.
// This test updated for merged engine/server
// Check that worker task doesn't run twice in same context
@dispatch=WORKER
(int o) worker_task (int i) "turbine" "0.0.1" [
"set <<o>> <<i>>; if { $turbine::mode != \"WORKE... |
Add moves(to:) method to Sequence | //
// Sequence+Fischer.swift
// Fischer
//
// Copyright 2016 Nikolai Vazquez
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//... | //
// Sequence+Fischer.swift
// Fischer
//
// Copyright 2016 Nikolai Vazquez
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//... |
Split example tests in two tests: how to run a single or multiple native feature files. | //
// ExampleNativeFeatureTest.swift
// XCTest-Gherkin
//
// Created by Marcin Raburski on 30/06/2016.
// Copyright © 2016 CocoaPods. All rights reserved.
//
import XCTest
import XCTest_Gherkin
class ExampleNativeFeatureTest: NativeTestCase {
override func setUp() {
super.setUp()
let... | //
// ExampleNativeFeatureTest.swift
// XCTest-Gherkin
//
// Created by Marcin Raburski on 30/06/2016.
// Copyright © 2016 CocoaPods. All rights reserved.
//
import XCTest
import XCTest_Gherkin
class RunSingleFeatureFileTest: NativeTestCase {
override func setUp() {
super.setUp()
let... |
Use AnyObject instead of class in protocol requirements | //
// SignalBroadcasting.swift
// Beacon
//
// Created by Zhu Shengqi on 14/06/2017.
// Copyright © 2017 zetasq. All rights reserved.
//
import Foundation
public protocol BroadcastIdentifiable: RawRepresentable {
var rawValue: String { get }
}
public protocol SignalBroadcasting: class {
associatedty... | //
// SignalBroadcasting.swift
// Beacon
//
// Created by Zhu Shengqi on 14/06/2017.
// Copyright © 2017 zetasq. All rights reserved.
//
import Foundation
public protocol BroadcastIdentifiable: RawRepresentable {
var rawValue: String { get }
}
public protocol SignalBroadcasting: AnyObject {
associat... |
Order defaults to method GET | import Quick
import Nimble
import Faro
@testable import Faro_Example
class OrderSpec: QuickSpec {
override func spec() {
describe("Order") {
context("initialisation") {
it("should have a path"){
let expected = "path"
let order = Order(pat... | import Quick
import Nimble
import Faro
@testable import Faro_Example
class OrderSpec: QuickSpec {
override func spec() {
describe("Order") {
let expected = "path"
let order = Order(path: expected)
context("initialisation") {
it("should have a path"){
... |
Test the equivalence of Pair encodings. | // Copyright © 2015 Rob Rix. All rights reserved.
final class PairTests: XCTestCase {
func testModuleTypechecks() {
module.typecheck().forEach { XCTFail($0) }
}
}
private let module = Module<Term>.pair
import Manifold
import XCTest
| // Copyright © 2015 Rob Rix. All rights reserved.
final class PairTests: XCTestCase {
func testModuleTypechecks() {
module.typecheck().forEach { XCTFail($0) }
}
func testAutomaticallyEncodedDefinitionsAreEquivalentToHandEncodedDefinitions() {
expected.definitions.forEach { symbol, type, value in
assert(mod... |
Add convenience funcs for activating constraints | // Copyright (c) 2015 Steve Brambilla. All rights reserved.
import UIKit
/// Evaluates a distinct layout expression into a single constraint.
///
/// Returns an evaluated NSLayoutConstraint
public func evaluateLayoutExpression(_ expression: DistinctExpressionType) -> NSLayoutConstraint {
return expression.evaluateD... | // Copyright (c) 2015 Steve Brambilla. All rights reserved.
import UIKit
/// Evaluates a distinct layout expression into a single constraint.
///
/// Returns an evaluated NSLayoutConstraint
public func evaluateLayoutExpression(_ expression: DistinctExpressionType) -> NSLayoutConstraint {
return expression.evaluateD... |
Add present initial view controller method on app coordinators | //
// AppCoordinator
// Cruciverber
//
// Created by Cihat Gündüz on 12.03.16.
// Copyright © 2016 Flinesoft. All rights reserved.
//
import UIKit
/// This class is a coordinator for screen flows starting on app start / using windows.
open class AppCoordinator: Coordinator {
// MARK: - Stored Instance Propert... | //
// AppCoordinator
// Cruciverber
//
// Created by Cihat Gündüz on 12.03.16.
// Copyright © 2016 Flinesoft. All rights reserved.
//
import UIKit
/// This class is a coordinator for screen flows starting on app start / using windows.
open class AppCoordinator: Coordinator {
// MARK: - Stored Instance Propert... |
Add date parameter to trace | //
// NSObject.swift
// DarkSwift
//
// Created by Dark Dong on 2017/5/26.
// Copyright © 2017年 Dark Dong. All rights reserved.
//
import Foundation
private var associatedObjectKey = 0
public extension NSObject {
func trace(funcname: String = #function, _ items: Any...) {
print(type(of: self), funcna... | //
// NSObject.swift
// DarkSwift
//
// Created by Dark Dong on 2017/5/26.
// Copyright © 2017年 Dark Dong. All rights reserved.
//
import Foundation
private var associatedObjectKey = 0
public extension NSObject {
func trace(timestamp: Bool = false, funcname: String = #function, _ items: Any...) {
if ... |
Work around for the date formatter issue where being within an hour of a component transition will display more components than desired. | //
// NSDateComponentsFormatter+Postfix.swift
// PartyUP
//
// Created by Fritz Vander Heide on 2016-03-25.
// Copyright © 2016 Sandcastle Application Development. All rights reserved.
//
import Foundation
extension NSDateComponentsFormatter {
func stringFromDate(startDate: NSDate,
toD... | //
// NSDateComponentsFormatter+Postfix.swift
// PartyUP
//
// Created by Fritz Vander Heide on 2016-03-25.
// Copyright © 2016 Sandcastle Application Development. All rights reserved.
//
import Foundation
extension NSDateComponentsFormatter {
func stringFromDate(startDate: NSDate,
toD... |
Move Dropbox key appo separate variable and add warning for missing value | //
// AppDelegate.swift
// Vandelay
//
// Created by Daniel Saidi on 06/07/2016.
// Copyright © 2016 Daniel Saidi. All rights reserved.
//
import UIKit
import SwiftyDropbox
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: U... | //
// AppDelegate.swift
// Vandelay
//
// Created by Daniel Saidi on 06/07/2016.
// Copyright © 2016 Daniel Saidi. All rights reserved.
//
import UIKit
import SwiftyDropbox
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
var dropboxAppKey = ""
f... |
Update Swift tools version to Swift 5.2 | // swift-tools-version:5.1
import PackageDescription
let package = Package(
name: "Differ",
products: [
.library(name: "Differ", targets: ["Differ"]),
],
targets: [
.target(name: "Differ"),
.testTarget(name: "DifferTests", dependencies: ["Differ"]),
]
)
| // swift-tools-version:5.2
import PackageDescription
let package = Package(
name: "Differ",
products: [
.library(name: "Differ", targets: ["Differ"]),
],
targets: [
.target(name: "Differ"),
.testTarget(name: "DifferTests", dependencies: [
.target(name: "Differ")
... |
Add Task and UserDefaults to Service Provider | //
// ServiceProvider.swift
// Zero
//
// Created by Jairo Eli de Leon on 5/8/17.
// Copyright © 2017 Jairo Eli de León. All rights reserved.
//
protocol ServiceProviderType: class {}
final class ServiceProvider: ServiceProviderType {}
| //
// ServiceProvider.swift
// Zero
//
// Created by Jairo Eli de Leon on 5/8/17.
// Copyright © 2017 Jairo Eli de León. All rights reserved.
//
protocol ServiceProviderType: class {
var userDefaultsService: UserDefaultsServiceType { get }
var taskService: TaskServiceType { get }
}
final class ServiceProvider... |
Make the DispatchQoS extension internal when building from Xcode | //
// dispatchqos.swift
// deferred
//
// Created by Guillaume Lessard on 31/08/2016.
// Copyright © 2016 Guillaume Lessard. All rights reserved.
//
import Dispatch
extension DispatchQoS
{
public static func current(fallback: DispatchQoS.QoSClass = .utility) -> DispatchQoS
{
let qos = DispatchQoS.QoSClass... | //
// dispatchqos.swift
// deferred
//
// Created by Guillaume Lessard on 31/08/2016.
// Copyright © 2016 Guillaume Lessard. All rights reserved.
//
import Dispatch
extension DispatchQoS
{
#if SWIFT_PACKAGE
public static func current(fallback: DispatchQoS.QoSClass = .utility) -> DispatchQoS
{
let qos = Di... |
Add example code for selected demo. | //
// ViewController.swift
// CHCarouselView
//
// Created by Calvin on 8/5/16.
// Copyright © 2016 CapsLock. All rights reserved.
//
import UIKit
import Kingfisher
class ViewController: UIViewController {
@IBOutlet weak var carouselView: CarouselView!
override func viewDidLoad() {
super.viewDidL... | //
// ViewController.swift
// CHCarouselView
//
// Created by Calvin on 8/5/16.
// Copyright © 2016 CapsLock. All rights reserved.
//
import UIKit
import Kingfisher
class ViewController: UIViewController {
@IBOutlet weak var carouselView: CarouselView!
override func viewDidLoad() {
super.viewDidL... |
Add injection for Xcode snippet | //
// AppDelegate.swift
// React
//
// Created by Sacha Durand Saint Omer on 29/03/2017.
// Copyright © 2017 Freshos. All rights reserved.
//
import UIKit
import Komponents
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIA... | //
// AppDelegate.swift
// React
//
// Created by Sacha Durand Saint Omer on 29/03/2017.
// Copyright © 2017 Freshos. All rights reserved.
//
import UIKit
import Komponents
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIA... |
Clean up, make S a variable |
/*
RECUR 1 SWIFT
Simply run with: 'swift-t recur-1.swift | nl'
*/
app (void v) dummy(string parent, int stage, int id, void block)
{
"echo" ("parent='%3s'"%parent) ("stage="+stage) ("id="+id) ;
}
N = 4;
void A[string];
(void v) runstage(int N, string parent, int stage, int id, void block)
{
string this = ... |
/*
RECUR 1 SWIFT
Simply run with: 'swift-t recur-1.swift | nl'
*/
app (void v) dummy(string parent, int stage, int id, void block)
{
"echo" ("parent='%3s'"%parent) ("stage="+stage) ("id="+id) ;
}
N = 4; // Data split factor
S = 3; // Maximum stage number (tested up to S=7, 21,844 dummy tasks)
(void v) runsta... |
Fix compatible iOS / OSX | //
// OAuthSwiftURLHandlerType.swift
// OAuthSwift
//
// Created by phimage on 11/05/15.
// Copyright (c) 2015 Dongri Jin. All rights reserved.
//
import AppKit
@objc public protocol OAuthSwiftURLHandlerType {
func handle(url: NSURL)
}
public class OAuthSwiftOpenURLExternally: OAuthSwiftURLHandlerType {
... | //
// OAuthSwiftURLHandlerType.swift
// OAuthSwift
//
// Created by phimage on 11/05/15.
// Copyright (c) 2015 Dongri Jin. All rights reserved.
//
import Foundation
#if os(iOS)
import UIKit
#elseif os(OSX)
import AppKit
#endif
@objc public protocol OAuthSwiftURLHandlerType {
func handle(url: NSURL)
}... |
Write the string plist for the article. | //
// ArticlePasteboardWriter.swift
// Evergreen
//
// Created by Brent Simmons on 11/6/17.
// Copyright © 2017 Ranchero Software. All rights reserved.
//
import Cocoa
import Data
@objc final class ArticlePasteboardWriter: NSObject, NSPasteboardWriting {
private let article: Article
init(article: Article) {
... | //
// ArticlePasteboardWriter.swift
// Evergreen
//
// Created by Brent Simmons on 11/6/17.
// Copyright © 2017 Ranchero Software. All rights reserved.
//
import Cocoa
import Data
@objc final class ArticlePasteboardWriter: NSObject, NSPasteboardWriting {
private let article: Article
init(article: Article) {
... |
Update Notifications Center collection view layout. | import UIKit
final class NotificationsCenterView: SetupView {
// MARK: - Properties
lazy var collectionView: UICollectionView = {
return UICollectionView(frame: .zero, collectionViewLayout: UICollectionViewFlowLayout())
}()
// MARK: - Setup
override func setup() {
backgroundColo... | import UIKit
final class NotificationsCenterView: SetupView {
// MARK: - Properties
lazy var collectionView: UICollectionView = {
let collectionView = UICollectionView(frame: .zero, collectionViewLayout: tableStyleLayout)
collectionView.register(NotificationsCenterCell.self, forCellWithReuseIdentifier: Noti... |
Update response mapping for transit | //
// TransitRoutes.swift
// Pods
//
// Created by John Neyer on 8/24/17.
//
//
import Foundation
import ObjectMapper
public class TransitRoutes : RestResponse {
var results: Int?
var route: Int?
var buses: [TransitRoute]?
public override func mapping(map: Map) {
super.mappin... | //
// TransitRoutes.swift
// Pods
//
// Created by John Neyer on 8/24/17.
//
//
import Foundation
import ObjectMapper
public class TransitRoutes : RestResponse {
var results: Int?
var route: Int?
var transit: [TransitRoute]?
public override func mapping(map: Map) {
super.mapp... |
Correct Min MacOS version for CoreBluetooth Framework | // swift-tools-version:5.0
// The swift-tools-version declares the minimum version of Swift required to build this package.
import PackageDescription
let package = Package(
name: "RxBluetoothKit",
platforms: [
.macOS(.v10_10), .iOS(.v8), .tvOS(.v11), .watchOS(.v4)
],
products: [
.libra... | // swift-tools-version:5.0
// The swift-tools-version declares the minimum version of Swift required to build this package.
import PackageDescription
let package = Package(
name: "RxBluetoothKit",
platforms: [
.macOS(.v10_13), .iOS(.v8), .tvOS(.v11), .watchOS(.v4)
],
products: [
.libra... |
Add Swift version to conditions | //
// shim.swift
// Yams
//
// Created by Norio Nomura 1/27/18.
// Copyright (c) 2018 Yams. All rights reserved.
//
#if !swift(>=4.1)
extension Sequence {
func compactMap<ElementOfResult>(
_ transform: (Self.Element
) throws -> ElementOfResult?) rethrows -> [ElementOfResult] {
... | //
// shim.swift
// Yams
//
// Created by Norio Nomura 1/27/18.
// Copyright (c) 2018 Yams. All rights reserved.
//
#if !swift(>=4.1)
extension Sequence {
func compactMap<ElementOfResult>(
_ transform: (Self.Element
) throws -> ElementOfResult?) rethrows -> [ElementOfResult] {
... |
Remove completion block from update operation | //
// UpdateDataOperation.swift
// CriticalMaps
//
// Created by Илья Глущук on 13/10/2019.
// Copyright © 2019 Pokus Labs. All rights reserved.
//
import Foundation
final class UpdateDataOperation: AsyncOperation {
private struct SendLocationPostBody: Encodable {
let device: String
let locati... | //
// UpdateDataOperation.swift
// CriticalMaps
//
// Created by Илья Глущук on 13/10/2019.
// Copyright © 2019 Pokus Labs. All rights reserved.
//
import Foundation
final class UpdateDataOperation: AsyncOperation {
private struct SendLocationPostBody: Encodable {
let device: String
let locati... |
Fix users detail title presentation at navigation bar | //
// UserDetailPresenter.swift
// RandomUser
//
// Created by Toni on 02/07/2017.
// Copyright © 2017 Random User Inc. All rights reserved.
//
import Foundation
import BothamUI
class UserDetailPresenter: BothamPresenter {
fileprivate let username: String
fileprivate let getUserDetail: GetUserDetail
filepri... | //
// UserDetailPresenter.swift
// RandomUser
//
// Created by Toni on 02/07/2017.
// Copyright © 2017 Random User Inc. All rights reserved.
//
import Foundation
import BothamUI
class UserDetailPresenter: BothamPresenter {
fileprivate let username: String
fileprivate let getUserDetail: GetUserDetail
filepri... |
Add a method to be able to transform BothamError into Todo api client errors | //
// TODOAPIClientError.swift
// KataTODOAPIClient
//
// Created by Pedro Vicente Gomez on 12/02/16.
// Copyright © 2016 Karumi. All rights reserved.
//
import Foundation
public enum TODOAPIClientError: ErrorType {
case NetworkError
case ItemNotFound
case UnknownError
} | //
// TODOAPIClientError.swift
// KataTODOAPIClient
//
// Created by Pedro Vicente Gomez on 12/02/16.
// Copyright © 2016 Karumi. All rights reserved.
//
import Foundation
import Result
import BothamNetworking
public enum TODOAPIClientError: ErrorType {
case NetworkError
case ItemNotFound
case Unknow... |
Update test expectations. Not sure why this number changed from a few minutes ago. | //
// FileUtilsTests.swift
// WebKittyTests
//
// Created by Steve Baker on 3/19/15.
// Copyright (c) 2015 Beepscore LLC. All rights reserved.
//
import XCTest
class FileUtilsTests: XCTestCase {
var fileUtils: FileUtils?
override func setUp() {
super.setUp()
// Put setup code here. This ... | //
// FileUtilsTests.swift
// WebKittyTests
//
// Created by Steve Baker on 3/19/15.
// Copyright (c) 2015 Beepscore LLC. All rights reserved.
//
import XCTest
class FileUtilsTests: XCTestCase {
var fileUtils: FileUtils?
override func setUp() {
super.setUp()
// Put setup code here. This ... |
Improve 'announce' logic when VoiceOver is not active. | //
// AccessibilityInstructions.swift
// Access
//
// Created by David Sweetman on 11/29/15.
// Copyright © 2016. All rights reserved.
//
import UIKit
public class VO {
private init() {}
public enum AccessibilityEventType {
case Layout
case ScreenChange
func value() -> UI... | //
// AccessibilityInstructions.swift
// Access
//
// Created by David Sweetman on 11/29/15.
// Copyright © 2016. All rights reserved.
//
import UIKit
public class VO {
private init() {}
public enum AccessibilityEventType {
case Layout
case ScreenChange
func value() -> UI... |
Change return value type UIResponder to Event.Responder | //
// Stimulator.swift
// Pods
//
// Created by Yuki Takahashi on 2015/07/29.
//
//
import Foundation
public protocol Event {
typealias Responder
func stimulate(responder: Responder)
}
public extension UIResponder {
public func stimulate<E: Event>(event: E) -> UIResponder? {
var responde... | //
// Stimulator.swift
// Pods
//
// Created by Yuki Takahashi on 2015/07/29.
//
//
import Foundation
public protocol Event {
typealias Responder
func stimulate(responder: Responder)
}
public extension UIResponder {
public func stimulate<E: Event>(event: E) -> E.Responder? {
var responde... |
Mark removed method as unavailable for easier migration | // Copyright © 2020 Flinesoft. All rights reserved.
/// Simple protocol to make modifying objects with multiple properties more pleasant (functional, chainable, point-free).
public protocol Withable { /* no requirements */ }
extension Withable {
/// Create a copy (if a struct) or use same object (if class), impro... | // Copyright © 2020 Flinesoft. All rights reserved.
/// Simple protocol to make modifying objects with multiple properties more pleasant (functional, chainable, point-free).
public protocol Withable { /* no requirements */ }
extension Withable {
@available(*, unavailable, message: "Add `().with` after the type na... |
Add Reusable protocol declaration to scrollview | import UIKit
class PagingScrollView: UIScrollView {
var reusableViews = [UIView]()
override init(frame: CGRect) {
super.init(frame: frame)
configure()
}
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
configure()
}
func configure() {
pagingEnabled = true
di... | import UIKit
protocol Reusable: class {
func prepareForReuse()
}
class PagingScrollView: UIScrollView {
var reusableViews = [UIView]()
override init(frame: CGRect) {
super.init(frame: frame)
configure()
}
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
configure()
... |
Revert to IBM-Swift/SwiftyJSON for Linux support | import PackageDescription
let package = Package(
name: "zosconnectforswift",
targets: [],
dependencies: [
.Package(url: "https://github.com/SwiftyJSON/SwiftyJSON.git", versions: Version(1,0,0)..<Version(3, .max, .max)),
.Package(url: "https://github.com/IBM-Swift/Kitura-net",
majorVer... | import PackageDescription
let package = Package(
name: "zosconnectforswift",
targets: [],
dependencies: [
.Package(url: "https://github.com/IBM-Swift/SwiftyJSON", versions: Version(1,0,0)..<Version(15, .max, .max)),
.Package(url: "https://github.com/IBM-Swift/Kitura-net",
majorVersion... |
Implement pinch to zoom in media viewer | //
// MediaViewerController.swift
// AtMe
//
// Created by Joel Rorseth on 2018-04-28.
// Copyright © 2018 Joel Rorseth. All rights reserved.
//
import UIKit
class MediaViewerController: UIViewController {
var contentImageView: UIImageView!
var image: UIImage?
override func viewDidLoad() {
... | //
// MediaViewerController.swift
// AtMe
//
// Created by Joel Rorseth on 2018-04-28.
// Copyright © 2018 Joel Rorseth. All rights reserved.
//
import UIKit
class MediaViewerController: UIViewController {
var scrollView: UIScrollView!
var contentImageView: UIImageView!
var image: UIImage?
overri... |
Add ReactiveKit as test dependency | // swift-tools-version:4.2
import PackageDescription
let package = Package(
name: "Bond",
products: [
.library(name: "Bond", targets: ["Bond"])
],
dependencies: [
.package(url: "https://github.com/DeclarativeHub/ReactiveKit.git", .upToNextMajor(from: "3.10.0")),
.package(url: "h... | // swift-tools-version:4.2
import PackageDescription
let package = Package(
name: "Bond",
products: [
.library(name: "Bond", targets: ["Bond"])
],
dependencies: [
.package(url: "https://github.com/DeclarativeHub/ReactiveKit.git", .upToNextMajor(from: "3.10.0")),
.package(url: "h... |
Add new yellow and red colors | //
// Created by Alexander Maslennikov on 27.01.16.
// Copyright (c) 2016 Heads and Hands. All rights reserved.
//
import UIKit
import ChameleonFramework
extension UIColor {
static func hhkl_mainColor() -> UIColor {
return UIColor.flatBlackColorDark()
}
static func hhkl_secondaryColor() -> UICol... | //
// Created by Alexander Maslennikov on 27.01.16.
// Copyright (c) 2016 Heads and Hands. All rights reserved.
//
import UIKit
import ChameleonFramework
extension UIColor {
static func hhkl_mainColor() -> UIColor {
return UIColor.flatBlackColorDark()
}
static func hhkl_secondaryColor() -> UICol... |
Remove check for auto play | import UIKit
extension UIViewController {
// MARK: - Method Swizzling
public override class func initialize() {
struct Static {
static var token: dispatch_once_t = 0
}
if self !== UIViewController.self { return }
dispatch_once(&Static.token) {
MethodSwizzler.swizzleMethod("viewWillA... | import UIKit
extension UIViewController {
// MARK: - Method Swizzling
public override class func initialize() {
struct Static {
static var token: dispatch_once_t = 0
}
if self !== UIViewController.self { return }
dispatch_once(&Static.token) {
MethodSwizzler.swizzleMethod("viewWillA... |
Add string helper for nil or empty | /*
| _ ____ ____ _
| | |‾| ⚈ |-| ⚈ |‾| |
| | | ‾‾‾‾| |‾‾‾‾ | |
| ‾ ‾ ‾
*/
import UIKit
public extension String {
func height(with width: CGFloat, font: UIFont = UIFont.preferredFont(forTextStyle: .body)) -> CGFloat {
let nsString = self as NSString
let rect = ns... | /*
| _ ____ ____ _
| | |‾| ⚈ |-| ⚈ |‾| |
| | | ‾‾‾‾| |‾‾‾‾ | |
| ‾ ‾ ‾
*/
import UIKit
public extension String {
func height(with width: CGFloat, font: UIFont = UIFont.preferredFont(forTextStyle: .body)) -> CGFloat {
let nsString = self as NSString
let rect = ns... |
Add test for RequestBuilder init | //
// RequestBuilderTests.swift
// BreweryDB
//
// Created by Jake Welton on 1/30/16.
// Copyright © 2016 Jake Welton. All rights reserved.
//
import XCTest
class RequestBuilderTests: XCTestCase {
override func setUp() {
super.setUp()
// Put setup code here. This method is called before t... | //
// RequestBuilderTests.swift
// BreweryDB
//
// Created by Jake Welton on 1/30/16.
// Copyright © 2016 Jake Welton. All rights reserved.
//
import XCTest
@testable import BreweryDB
class RequestBuilderTests: XCTestCase {
override func setUp() {
super.setUp()
// Put setup code here. Thi... |
Add a missing REQUIRES and availability macro. | // RUN: %target-swift-frontend -emit-sil %s -Onone -Xllvm \
// RUN: -sil-print-after=mandatory-inlining \
// RUN: -enable-ownership-stripping-after-serialization \
// RUN: -Xllvm -sil-print-debuginfo -o /dev/null 2>&1 | %FileCheck %s
// CHECK: begin_borrow {{.*}} : $OSLog, loc {{.*}}, scope 3
// CHECK: tuple (),... | // REQUIRES: objc_interop
// RUN: %target-swift-frontend -emit-sil %s -Onone -Xllvm \
// RUN: -sil-print-after=mandatory-inlining \
// RUN: -enable-ownership-stripping-after-serialization \
// RUN: -Xllvm -sil-print-debuginfo -o /dev/null 2>&1 | %FileCheck %s
// CHECK: begin_borrow {{.*}} : $OSLog, loc {{.*}}, ... |
Update way to deserialize only with functional operations | //
// FirebaseModel+Extension.swift
// FirebaseCommunity
//
// Created by Victor Alisson on 15/08/17.
//
import Foundation
import FirebaseCommunity
public extension FirebaseModel {
typealias JSON = [String: Any]
internal static var classPath: DatabaseReference {
return reference.child(Self.cla... | //
// FirebaseModel+Extension.swift
// FirebaseCommunity
//
// Created by Victor Alisson on 15/08/17.
//
import Foundation
import FirebaseCommunity
public extension FirebaseModel {
typealias JSON = [String: Any]
internal static var classPath: DatabaseReference {
return reference.child(Self.cla... |
Increase version number in swcomp | // Copyright (c) 2017 Timofey Solomko
// Licensed under MIT License
//
// See LICENSE for license information
import Foundation
import SWCompression
import SwiftCLI
let cli = CLI(name: "swcomp", version: "4.0.0-test.1",
description: """
swcomp - small command-line client for S... | // Copyright (c) 2017 Timofey Solomko
// Licensed under MIT License
//
// See LICENSE for license information
import Foundation
import SWCompression
import SwiftCLI
let cli = CLI(name: "swcomp", version: "4.0.0-test.2",
description: """
swcomp - small command-line client for S... |
Check based on equality, not identity | //
// ExpressionRewriter.swift
// DDMathParser
//
// Created by Dave DeLong on 8/25/15.
//
//
import Foundation
public struct ExpressionRewriter {
private var rules: Array<RewriteRule>
public init(rules: Array<RewriteRule> = RewriteRule.defaultRules) {
self.rules = rules
}
public ... | //
// ExpressionRewriter.swift
// DDMathParser
//
// Created by Dave DeLong on 8/25/15.
//
//
import Foundation
public struct ExpressionRewriter {
private var rules: Array<RewriteRule>
public init(rules: Array<RewriteRule> = RewriteRule.defaultRules) {
self.rules = rules
}
public ... |
Read only *.json data files | //
// main.swift
// awesome-creator
//
// Created by Caesar Wirth on 4/13/15.
// Copyright (c) 2015 Caesar Wirth. All rights reserved.
//
import Foundation
func dataFilePaths() -> [String] {
var paths: [String] = []
let fileManager = NSFileManager.defaultManager()
if let datas = fileManager.contents... | //
// main.swift
// awesome-creator
//
// Created by Caesar Wirth on 4/13/15.
// Copyright (c) 2015 Caesar Wirth. All rights reserved.
//
import Foundation
func dataFilePaths() -> [String] {
var paths: [String] = []
let fileManager = NSFileManager.defaultManager()
if let datas = fileManager.contents... |
Add a test of MIMEType for linux. | /* *************************************************************************************************
MIMETypeTests.swift
© 2018 YOCKOW.
Licensed under MIT License.
See "LICENSE.txt" for more information.
************************************************************************************************ */
... | /* *************************************************************************************************
MIMETypeTests.swift
© 2018 YOCKOW.
Licensed under MIT License.
See "LICENSE.txt" for more information.
************************************************************************************************ */
... |
Use 5.0.0 version of cli framework | // swift-tools-version:4.0
import PackageDescription
let package = Package(
name: "SWCompression",
products: [
.library(
name: "SWCompression",
targets: ["SWCompression"]),
],
dependencies: [
// SWCOMP: Uncomment the line below to build swcomp example program.
... | // swift-tools-version:4.0
import PackageDescription
let package = Package(
name: "SWCompression",
products: [
.library(
name: "SWCompression",
targets: ["SWCompression"]),
],
dependencies: [
// SWCOMP: Uncomment the line below to build swcomp example program.
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.