lang
stringclasses
10 values
seed
stringlengths
5
2.12k
swift
/// /// - Parameters: /// - lhs: First file to be sorted. /// - rhs: Second file to be sorted. /// - Returns: True if the first workspace data element should be before the second one. private func workspaceDataElementSort(lhs: XCWorkspaceDataElement, rhs: XCWorkspaceDataElement) -> Bool { ...
swift
// This source file is part of the Swift.org open source project // Copyright (c) 2014 - 2016 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 li...
swift
final class HashableType: Hashable { private let type: Any.Type init(type: Any.Type) { self.type = type } func hash(into hasher: inout Hasher) { hasher.combine("\(type)") }
swift
// // See LICENSE.txt for license information // See CONTRIBUTORS.md for the list of Swift Distributed Actors project authors // // SPDX-License-Identifier: Apache-2.0 // //===----------------------------------------------------------------------===// @testable import DistributedActors import DistributedActorsTestKit
swift
//implements some of the base behaviors extension WebSocketClient { public func write(string: String) { write(string: string, completion: nil) }
swift
extension UIColor { convenience init(hex: NSInteger, alpha: CGFloat = 1) { let r: Int = (hex >> 16) let g: Int = (hex >> 8 & 0xFF)
swift
\((1...maxArity).map { generateInjectorFunc(arity: $0) }.joined(separator: "\n")) } """ try content.write(to: path, atomically: true, encoding: .utf8) } func generateInjectorFunc(arity: Int) -> String { let arityTypes = (1...arity).map { "T\($0)" }.joined(separator: ", ") let content = """
swift
// This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead). guard let _ = (scene as? UIWindowScene) else { return } } func sceneDidDisconnect(_ scene: UIScene) { // Called as the scene is being released by t...
swift
let myRequest = NSURLRequest(URL: url!) // Configure session so that completion handler is executed on main UI thread let session = NSURLSession( configuration: NSURLSessionConfiguration.defaultSessionConfiguration(), delegate:nil, delegateQueue:NSOpe...
swift
func testFileWithDefaults() { let parser = IconsJSONFileParser() do { try parser.parseFile(fixturePath("fontAwesome.json")) } catch { XCTFail("Exception while parsing file: \(error)") }
swift
import SotoCore @available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *) extension HealthLake { // MARK: Async API Calls
swift
XCTAssertTrue(action.has(tags: ["T1", "T2", "T3"], using: .and)) XCTAssertFalse(action.has(tags: ["T1", "T2", "T3", "T4"], using: .and)) /// .or condition XCTAssertTrue(action.has(tags: ["T3", "T4", "T5", "T6"], using: .or)) XCTAssertFalse(action.has(tags: ["T4", "T5", "T6", "T7"], using: .or))...
swift
import Foundation import UIKit public enum NotificationType { case info case done case warning case error }
swift
self.dataStoreConfiguration = dataStoreConfiguration self.syncEngine = syncEngine self.validAPIPluginKey = validAPIPluginKey self.validAuthPluginKey = validAuthPluginKey }
swift
// // RandomColorizationTests.swift // RandomColorizationTests // // Created by Allen on 16/1/14. // Copyright © 2016年 Allen. All rights reserved.
swift
import Cocoa import Contacts @NSApplicationMain class AppDelegate: NSObject, NSApplicationDelegate { static let contactStore = CNContactStore() func applicationDidFinishLaunching(_ aNotification: Notification) {
swift
// // String-Ext.swift // QKMRZParser // // Created by Matej Dorcak on 14/10/2018. // import Foundation // MARK: Parser related extension String { func trimmingFillers() -> String { return trimmingCharacters(in: CharacterSet(charactersIn: "<"))
swift
// MetalCommandQueue.swift // // // Created by Thomas Roughton on 2/08/20. // #if canImport(Metal) import SubstrateUtilities
swift
// UITabBar+Extension.swift // Copyright (c) 2015-2016 Red Rain (http://mochxiao.com). // // 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, including without limita...
swift
struct JSONDomain { struct BookResponse: Equatable, Codable { let items: [Book]? } struct Book: Equatable, Codable { let id: String
swift
let blockList = blockLists.first ?? [] self.readWithoutEncryption(serviceCodeList: [serviceCode], blockList: blockList) { (status1, status2, blockData, error) in if let error = error { completionHandler(status1, status2, blockData, error) return ...
swift
// MARK: UISceneSession Lifecycle func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration { // Called when a new scene session is being created. // Use this method to select a ...
swift
self.navigationItem.leftBarButtonItem = UIBarButtonItem(image: UIImage(named:"cancel"), style:.Done, target:self, ...
swift
static func assembleModule() -> UIViewController { let view = getSelfUIViewController() as! RootViewController let presenter = RootPresenterImpl() let interactor = RootInteractorImpl() let navigation = UINavigationController(rootViewController...
swift
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. // Use this method to paus...
swift
return UIColor(red: 0.4039, green: 0.8392, blue: 0.3608, alpha: 1.0) } func stop() -> UIColor { return UIColor(red: 1.0, green: 0.1879, blue: 0.0589, alpha: 1.0) }
swift
self.exporter = exporter } public func strategy<Element>(for parameter: EndpointParameter<Element>) -> AnyParameterDecodingStrategy<Element, IE.ExporterRequest> where Element: Decodable, Element: Encodable {
swift
// import Alamofire import SwiftyJSON
swift
/****************************/ /******* View Actions *******/ /****************************/ @IBAction func redeemReward(_ sender: Any) { timer = Timer.scheduledTimer(timeInterval: 1, target: self, selector: #selector(WalletPopUpViewController.counter), userInfo: nil, repeats: true) rewardRe...
swift
import XCTest import Nimble @testable import SwiftySlack //final class SwiftySlackTests: XCTestCase { // // // static var allTests = [ // ] //}
swift
// Created by lishengfeng on 2018/3/10. // Copyright © 2018年 李胜锋. All rights reserved. // import Foundation public extension NSObject { func codableProperties() -> [String: Any?] { var codableProperites = [String: Any?]() let mirror = Mirror.init(reflecting: self) for (labe...
swift
} func decode<T: Decodable>(_ type: T.Type) throws -> T { switch type { case is Data.Type: return try decode(Data.self) as! T case is Date.Type: return try decode(Date.self) as! T default: let decoder = _CBORDecoder(data: self.data) ...
swift
self.name = name self.address = address } var description: String { switch (name, address) { case let (name?, address?): return "name: \(name), address: \(address)" case let (name?, _): return "name: \(name)" case let (_, address?): return "address...
swift
import Foundation public enum UploadingState { case uploading(uploadRequestID: UUID?, progress: Double) case completed(uploadRequestID: UUID?, data: Data)
swift
} else{ tipNameLabel.text = "Tip" payNameLabel.text = "pay" } let billAmount = NSString(string: billField.text!).doubleValue
swift
// ViewController.swift // Example // // Created by Muhammad Bassio on 3/4/18. // Copyright © 2018 Muhammad Bassio. All rights reserved. // import UIKit import FluidKit class ViewController: FKTabBarController { override func viewDidLoad() {
swift
See https://swift.org/LICENSE.txt for license information See https://swift.org/CONTRIBUTORS.txt for Swift project authors */ /// Inline elements that should be rendered with a strike through them. public struct Strikethrough: RecurringInlineMarkup, BasicInlineContainer { public var _data: _MarkupData init(_...
swift
* You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See th...
swift
public func validate(file: SwiftLintFile) -> [StyleViolation] { func lineCountWithoutComments() -> Int { let commentKinds = SyntaxKind.commentKinds let lineCount = file.syntaxKindsByLines.filter { kinds in return !Set(kinds).isSubset(of: commentKinds) }.co...
swift
do { let decoder = JSONDecoder() let decodedObject: T = try decoder.decode(T.self, from: data) completion(decodedObject, nil) } catch { completion(nil, .decoding)
swift
import Base.ExplicitSub import Base.ExplicitSub.ImSub import Base.ExplicitSub.ExSub import MostlyPrivate1 import MostlyPrivate1_Private // Deliberately not importing MostlyPrivate2 import MostlyPrivate2_Private @objc class Test { @objc let word: DWORD = 0 @objc let number: TimeInterval = 0.0
swift
return true case let (.identifier(id1), .identifier(id2)): return id1 == id2 case let (.number(n1), .number(n2)): return n1 == n2 case let (.operator(op1), .operator(op2)): return op1 == op2 default: return false
swift
newHeaders.appendRegularHeaders(from: oldHeaders) self.init(newHeaders) } } extension Array where Element == (String, String) {
swift
import Foundation // Gather coverage for modified files Coverage.xcodeBuildCoverage(.derivedDataFolder("./.build/DerivedData"), minimumCoverage: 50, excludedTargets: [])
swift
// // SwiftLedEntryPoint.swift // swiftled-2 // // Created by Michael Lewis on 7/29/16. // // import Foundation import OPC import RxSwift import Cleanse
swift
/** * Apps Portfolio * * Copyright (c) 2017 Mahmud Ahsan. Licensed under the MIT license, as follows: * * 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, includ...
swift
public static let emptyViewTitleOpacity: CGFloat = 0.3 public static let titleFont = ArduinoTypography.boldFont(forSize: ArduinoTypography.FontSize.Small.rawValue) public static let subtitleFont = ArduinoTypography.boldFont(forSize: ArduinoTypography.FontSize.XSmall.rawValue) public static let flatButtonFont...
swift
} else { println("Error initializing model from: \(modelURL)") } } else { println("Could not find data model in app bundle") } abort() } () func application(application: UIApplication, didFinishLaunchingWithOptions launchOpti...
swift
// CHECK: decl: var arr3: [Myclass1] // CHECK: type: Array<Myclass1> arr3.append(Myclass1()) // CHECK: type: (@lvalue Array<Myclass1>) -> (Myclass1) -> () _ = Myclass2.init() // CHECK: dref: init() } }
swift
class HQBViewModel: CustomStringConvertible { var model: HQBModel init(model: HQBModel) { self.model = model }
swift
return false } } return true }
swift
print("create account tapped...") } func configureTextFields() { passwordTFV.configure(leftImage: UIImage(named: "password"), placeHolder: "Enter Password") firstNameTFV.configure(leftImage: UIImage(named: "user"), placeHo...
swift
/// The preferred view size for the view, width will be ignored for ListSpot cells open var preferredViewSize = CGSize(width: 0, height: 44) /// An optional reference to the current item open var item: Item? /// Initializes a table cell with a style and a reuse identifier and returns it to the caller. ///...
swift
// 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 agreed to in writing, software // distributed unde...
swift
self.present(nav, animated: true, completion: nil) } } // MARK: - ZJProfileHeadViewDelegate extension ZJProfileViewController : ZJProfileHeadViewDelegate { func zj_loginBtnAction(sender: UIButton) { UIApplication.shared.keyWindow?.addSubview(self.loginView)
swift
struct DragableImage: View { let url: URL var body: some View { Image(uiImage: UIImage(contentsOfFile: url.path)!) .resizable() .frame(width: 150, height: 150) .clipShape(Circle()) .overlay(Circle().stroke(Color.white, lineWidth: 2))
swift
// Copyright © 2015 Roy Marmelstein. All rights reserved. // import Foundation #if os(iOS) import CoreTelephony #endif public final class PhoneNumberKit: NSObject { // Manager objects let metadataManager = MetadataManager() let parseManager: ParseManager
swift
import Foundation class Phone { private let phoneOwner: Person init(phoneOwner: Person){ self.phoneOwner = phoneOwner }
swift
innerRadiusTR = presentationLayer.borderTopRightInnerRadius innerRadiusBL = presentationLayer.borderBottomLeftInnerRadius innerRadiusBR = presentationLayer.borderBottomRightInnerRadius layerW = presentationLayer.bounds.size.width layerH = presentationLayer.bounds.size.height } else { borderWidthT...
swift
} else if finalY < Double(self.height/8*4.25) + Double(frameInset.top) { finalY = Double(self.height/8*4.25) + Double(frameInset.top) } UIView.animate(withDuration: durationAnimation * 5, delay: 0, usingSpringWithDamping: 0.8, initialSpringVelocity: 6, o...
swift
import XCTest extension XCUIElement { /** Types text into the textField. Clear previous content if specified. - parameters:
swift
// case .login(let email, let password): // params["email"] = email // params["password"] = password // case .register(let email, let password, let phone): // params["email"] = email
swift
} @IBAction func costDone(_ sender: UITextField) { sender.resignFirstResponder() } @IBAction func iconDone(_ sender: UITextField) { sender.resignFirstResponder() } @IBAction func dropdownButtonAction(_ sender: Any) { guard let popupScreenViewController = st...
swift
return lhsType == rhsType case let (.nib(lhsNib), .nib(rhsNib)): return lhsNib === rhsNib default: return false } } }
swift
class FakeChannelTests: GRPCTestCase { typealias Request = Echo_EchoRequest typealias Response = Echo_EchoResponse var channel: FakeChannel!
swift
static let eraser = AttributesStream.ToolStyle(width: 10, color: nil) lazy var attributeStream = { () -> AttributesStream in let attributeStream = AttributesStream() attributeStream.styleOverride = { delta in switch delta { case .addedBezierPath(let index): ...
swift
} static var cancelButton: String { return NSLocalizedString("Add.CancelButton.text", comment: "") } static var noDataTitle: String { return NSLocalizedString("List.NoDataTitle.text", comment: "") }
swift
do { let jsonData = try jsonEncoder.encode(object) return try JSON(data: jsonData) } catch let error { XCTFail("Unable to encode the object: \(error).") } return JSON() } func jsonEncode<Value: Encodable>(object: Value) -> Data? { let jsonEncoder = JSONEncoder() jsonEncoder.outputFormatting = ....
swift
protocol BaseStyleType { func generalBackgroundColor() -> UIColor } // MARK: - CategoryPickerStyleType extension BaseStyleType {
swift
// // JsonCollectionViewCell.swift // LogFileViewer// Created by Mohankumar on 02/03/18. // Copyright © 2018 Mohankumar. All rights reserved. // import UIKit class JsonCollectionViewCell: UICollectionViewCell { }
swift
import SwiftUI extension View { func modal<V: View>( isPresented: Binding<Bool>, withNavigation: Bool = true, @ViewBuilder content: @escaping () -> V ) -> some View { background( EmptyView().sheet(isPresented: isPresented) { Group { ...
swift
// Do any additional setup after loading the view. } @IBAction func calculateTip(_ sender: Any) { let bill = Double(billAmountTextField.text!) ?? 0 let tipPercentages = [0.15, 0.18, 0.2] let tip = bill * tipPercentages[tipControl.selectedSegmentIndex]
swift
// Copyright © 2016 Pi Dynamics. All rights reserved. // import UIKit @UIApplicationMain
swift
// MIT license, see LICENSE file for details // import SwiftUI /// A view that reads an environment value of a key path. /// /// ```swift /// EnvironmentReader(\.theme) { theme in
swift
import Foundation import Tafelsalz protocol FileHandler { func encrypt(bytes: Bytes) throws -> Bytes func decrypt(bytes: Bytes) throws -> Bytes }
swift
import UIKit @testable import AlisterSwift class UpdateOpDelegate: ListControllerUpdateServiceInterface { var storageReloadCounter: Int = 0 var listReloadCounter: Int = 0 var updateCounter: Int = 0 func storageNeedsReload(_ identifier: String, isAnimated: Bool) { storageReloadCounter ...
swift
} extension PeopleViewController: UISearchBarDelegate { func searchBar(_ searchBar: UISearchBar, textDidChange searchText: String) { if let path = Bundle.main.path(forResource:"userinfo", ofType: "json") { let myUrl = URL.init(fileURLWithPath: path) if let data = try? Data.init(...
swift
import XCTest @testable import SwiftCohesionAnalyzerCore class SwiftCohesionAnalyzerTests: XCTestCase { func testExample() { XCTAssertEqual(1, 1) } static var allTests = [
swift
// // Copyright 2017-2019 rinsuki and other contributors. // // 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 requir...
swift
init(businessLogic: AuthenticationBusinessLogicType) { self.businessLogic = businessLogic setupBindings() } func onAppear() { businessLogic.authenticate() } } private extension AuthenticationViewModel {
swift
// Whalebird // // Created by akirafukushima on 2015/02/24. // Copyright (c) 2015年 AkiraFukushima. All rights reserved. //
swift
// // Created by Venkatnarayansetty, Badarinath on 4/25/20. // Copyright © 2020 CocoaPods. All rights reserved. // import Foundation import SwiftUI import StepperView
swift
private var components: URLComponents? init(_ base: String) { components = URLComponents(string: base) } func add(_ component: URLQueryItem) { components?.queryItems?.append(component) } func resolve() -> URL? { return components?.url } }
swift
encoder.label = "shadow buffer" encoder.setRenderPipelineState(renderPipelineState) encoder.setDepthStencilState(shadowDepthStencilState) encoder.setCullMode(.front) encoder.setDepthBias(0.01, slopeScale: 1.0, clamp: 0.01) renderer.renderCommandEn...
swift
// This source file is part of the Swift.org open source project // Copyright (c) 2014 - 2017 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 li...
swift
let normalizedSquareRect = CGRect(x: 0.25, y: 0.25, width: 0.25, height: 0.25) // Should have coordinates of // (575/1600, 225/900) 225/1600 x 225/900 // = (0.359375,0.25) 0.140625 x 0.25 let convertedRect = normalizedSquareRect.convertFromNormalizedCenterCropSquare(toOriginalS...
swift
let testCases: [TestCase] = [ (query: "", expectNumber: 0, isExpectSuccess: false, line: #line), (query: "name=master-ball", expectNumber: 0, isExpectSuccess: false, line: #line), (query: "number=not_number", expectNumber: 0, isExpectSuccess: false, line: #line), ...
swift
/// button to bring up the history screen private let historyButton = JGTapButton(frame: CGRect(x: 0,y: 0,width: 60,height: 60)) func setupActions(target: AnyObject?, settings: Selector, snap: Selector, locate: Selector, history: Selector) { self.axis = UILayoutConstraintAxis.Horizontal
swift
/// Defaults to `true`. public var pinchEnabled: Bool = true /// Whether rotation is enabled for the pinch gesture. /// Defaults to `true`. public var pinchRotateEnabled: Bool = true /// Whether the pitch gesture is enabled. Defaults to `true`. public var pitchEnabled: Bool = true ///...
swift
self.line = line } public var description: String { return value
swift
self.env = env } /// Also reachable via `Color.accentColor` @inlinable public var accentColor: Color? { get { env.value(of: Key.accentColor) } }
swift
} else { // Fallback on earlier versions } shadowView.layer.shadowOpacity = 1 shadowView.layer.shadowOffset = .zero shadowView.layer.shadowRadius = 5 }
swift
// See the License for the specific language governing permissions and // limitations under the License. // import Foundation /// Represents the homeserver configuration (usually based on HS Well-Known or hardoced values in the project) @objcMembers final class HomeserverConfiguration: NSObject { // Note: Us...
swift
class WeatherManager { var delegate : WeatherManagerDelegate? func fetchWeather(cityName: String){ NetworkService.request(router: .getCityWeather(cityName: cityName)) { (result: WeatherData) in let id = result.weather[0].id let temp = result.main.temp ...
swift
class A { func b func a let a=b protocol B{ class a{ class A{
swift
import Foundation class ReleaseNotesViewController: WebViewController { init?() { guard let aboutURL = WebViewController.websiteURL(withPath: "/releases") else { return nil } super.init(url: aboutURL)
swift
// // Errors.swift // // // Created by Allan Shortlidge on 12/31/20. //
swift
switch sender.selectedSegmentIndex { case 0: EditorViewController.indentation = "\t" case 1: EditorViewController.indentation = " " case 2:
swift
// Do any additional setup after loading the view. } override func didReceiveMemoryWarning() { super.didReceiveMemoryWarning() // Dispose of any resources that can be recreated. }
swift
/// /// - Parameters: /// - x: X轴偏移量 (x<0: 左移, x>0: 右移) axis offset (x <0: left, x> 0: right) /// - y: Y轴偏移量 (y<0: 上移, y>0: 下移) axis offset (Y <0: up, y> 0: down) func moveBadge(x: CGFloat, y: CGFloat) { base.badgeView.offset = CGPoint(x: x, y: y) base.centerYConstraint(with: b...