lang
stringclasses 10
values | seed
stringlengths 5
2.12k
|
---|---|
swift | let isOn = self.servicesPool.appSettingsService?.bool(forKey: .showOnlyKDBFiles) ?? true
showOnlyKDBFilesSwitch.setOn(isOn, animated: false)
showOnlyKDBFilesSwitch.addTarget(self, action: #selector(didToggleShowOnlyKDBFileSwitch(_:)), for: .valueChanged)
}
func getViewController() -> UIViewController {
return self
}
@objc func didToggleShowOnlyKDBFileSwitch(_ control: UISwitch) {
self.servicesPool.appSettingsService?.set(control.isOn, forKey: .showOnlyKDBFiles)
}
}
|
swift | modules = try! Environment(name: "modules", parent: nil);
}
// private
func finish() {
currentEnvironment = try! Environment(name: "next environemnt", parent: currentEnvironment); // TODO
}
func require<T :EnvironmentModule>(_ type : T.Type) throws -> Void {
let module = try modules!.getBean(type)
try buildModule(module: module as! EnvironmentModule)
}
|
swift |
func testPeopleTrackChargeZero() {
let testMixpanel = Mixpanel.initialize(token: randomId(), flushInterval: 60)
testMixpanel.identify(distinctId: "d1")
waitForTrackingQueue(testMixpanel) |
swift | //
import Foundation
import UIKit
import R2Shared
final class ReaderFactory { |
swift | XCTAssertEqual(mappedProject.targets.count, 2)
try XCTAssertSideEffectsCreateDerivedInfoPlist(
named: "A.plist",
content: ["A": "A_VALUE"],
projectPath: project.path,
sideEffects: sideEffects
)
try XCTAssertSideEffectsCreateDerivedInfoPlist(
named: "B.plist",
content: ["B": "B_VALUE"],
projectPath: project.path, |
swift | // Copyright © 2017 Prashant Mahajan. All rights reserved.
//
import UIKit
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { |
swift |
public struct Constant {
//Sanjeev's Detail
public static let SanjeevName = "Sanjeev Ghimire"
public static let SanjeevFB = "sanjeevfb"
public static let SanjeevLI = "sanjeevli"
public static let SanjeevTW = "sanjeevghimire"
public static let SanjeevPh = "859-864-9371"
public static let SanjeevLoc = "Austin, TX" |
swift | case fall
case pixelate
case sparkle
case burn
case anvil
public static let allValues = [
"Scale", "Evaporate", "Fall", "Pixelate", "Sparkle", "Burn", "Anvil"
]
public var description: String {
switch self {
case .evaporate: |
swift |
You've been provided with a a constant named `myAge` below that's already been assigned a value. Feel free to change the value of this constant to match your actual age.
Use that constant to create an `if-else` statement to print out `"Teenager"` if the value of `myAge` is greater or than 13 but less than or equal to 19, and to print out `"Not a teenager"` if the value is outside that range.
*/
// TODO: Write solution here
let myAge = 42
/*:
## Challenge 2
Create a constant named `teenagerName`, and use a ternary conditional operator to set the value of `teenagerName` to your own name as a string if the value of `myAge`, declared above, is greater than or equal to 13, but less than or equal to 19, and to set the value of `teenagerName` to `"Not me!"` if the value is outside that range.
Then print out the value of `teenagerName`. |
swift | //
import XCTest
@testable import ENA
class HomeTraceLocationsCellModelTests: CWATestCase {
func testGIVEN_HomeTraceLocationsCellModel_THEN_InitilizedAsExpected() {
// GIVEN |
swift | return KeyedEncodingContainer(ThrowingKeyedContainer(e))
}
func unkeyedContainer() -> UnkeyedEncodingContainer {
return ThrowingUnkeyedContainer(e)
}
func singleValueContainer() -> SingleValueEncodingContainer { |
swift |
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
extension Bundle {
static var myBundle : JJBundleDSL? {
return JJBundleDSL(mainBundleName: "JJBundle", anyClassNameInSameBundle: "JJBundle.JJBundleDSL")
}
} |
swift | public typealias SharingStrategy = DriverSharingStrategy
private let _lock = NSRecursiveLock()
private let _variable = BehaviorRelay(value: false)
private let _loading: SharedSequence<SharingStrategy, Bool>
public init() {
_loading = _variable.asDriver()
.distinctUntilChanged()
} |
swift | let snapshot = FIRDataSnapshotMock()
snapshot.childDictionary = ["id": 1, "first_name": [1:2], "last_name": 1.2, "me:": [1,2], "user_name": ["1": "2"], "email": ["1", "2"]]
var userExpected = User()
var userBefore = User()
var userAfter = User()
userBefore = userAfter
userAfter.parse(data: snapshot)
userExpected.parse(data: snapshot)
XCTAssertEqual(userBefore, userAfter)
XCTAssertEqual(userAfter, userExpected)
}
} |
swift | // RUN: %target-swift-ide-test -print-module-metadata -module-to-print Foo -enable-swiftsourceinfo -I %t -source-filename %s -serialized-path-obfuscate /FOO=/CHANGED_FOO -serialized-path-obfuscate /BAR=/CHANGED_BAR | %FileCheck %s --check-prefix=CHECK-RECOVER
public class A {}
// CHECK-ORIGINAL: /CHANGED_FOO/contents
// CHECK-ORIGINAL: /CHANGED_BAR/contents
|
swift |
class WMJPoperTransitionManager: NSObject,UIViewControllerTransitioningDelegate,UIViewControllerAnimatedTransitioning {
var isDismiss = false
var poperframe = CGRectZero
//MARK:-转场动画UIViewControllerTransitioningDelegate
// 该方法用于返回一个负责转场动画的对象
func presentationControllerForPresentedViewController(presented: UIViewController, presentingViewController presenting: UIViewController, sourceViewController source: UIViewController) -> UIPresentationController?{
let pc = WMJPresentationController(presentedViewController: presented, presentingViewController: presenting) |
swift |
@IBOutlet private weak var choreImageView: UIImageView!
@IBOutlet private weak var choreNameLabel: UILabel!
@IBOutlet private weak var pointsLabel: UILabel!
// MARK: - Methods
private func updateViews() {
let blue = UIColor(red: 0.02, green: 0.33, blue: 0.59, alpha: 1.0)
|
swift | /**
* Imagine Engine
* Copyright (c) John Sundell 2017
* See LICENSE file for license
*/
import Foundation
internal protocol Updatable: class {
func update(currentTime: TimeInterval) -> UpdateOutcome
}
|
swift | try expect(result) == "here"
}
}
func testSyntaxError() {
it("reports syntax error on invalid for tag syntax") {
self.template = "Hello {% for name in %}{{ name }}, {% endfor %}!"
try self.expectError(
reason: "'for' statements should use the syntax: `for <x> in <y> [where <condition>]`.",
token: "for name in"
)
} |
swift |
static let sharedInstance = Logger()
fileprivate func logger(_ level: Level, items: [Any], file: String, line: Int, column: Int) {
let result = formatter.format(
level: level,
items: items,
file: file,
line: line,
column: column |
swift | .failures()
.sink(receiveCompletion: { _ in self.completed = true },
receiveValue: { errors.append($0) })
subject.send("Hello")
subject.send("There")
subject.send("World!")
subject.send(completion: .failure(.someError))
XCTAssertEqual(errors, [.someError])
XCTAssertTrue(completed)
}
} |
swift | }
}
}
}
private extension TwitchResponder {
/// Checks whether a streamer is online.
func doChannelOnlineCheck(streamer: Streamers, channelName: String) -> ELF<Void> {
TwitchRoutes.isChannelLive(req, name: channelName)
.tryFlatMap { isOnline -> ELF<Void> in
if isOnline == true { |
swift | _commonInit()
}
public override init(frame: CGRect) {
super.init(frame: frame)
_commonInit() |
swift | }
}
return (interactiveNode, interactiveNodeBitMask)
}
func isInteractive() -> Bool {
return hasCategoryBit(bit: interactiveNodeBitMask)
} |
swift | super.viewDidLoad()
defer {
interactor?.fetchData()
}
view.backgroundColor = Colors.backgroundColor
configureTableView()
}
} |
swift | HighlightRule(pattern: linkOrImageRegex, formattingRule: TextFormattingRule(key: .underlineStyle, value: NSUnderlineStyle.single.rawValue)),
HighlightRule(pattern: boldRegex, formattingRule: TextFormattingRule(fontTraits: boldTraits)),
HighlightRule(pattern: asteriskEmphasisRegex, formattingRule: TextFormattingRule(fontTraits: emphasisTraits)),
HighlightRule(pattern: underscoreEmphasisRegex, formattingRule: TextFormattingRule(fontTraits: emphasisTraits)),
HighlightRule(pattern: boldEmphasisAsteriskRegex, formattingRule: TextFormattingRule(fontTraits: boldEmphasisTraits)),
HighlightRule(pattern: blockquoteRegex, formattingRule: TextFormattingRule(key: .backgroundColor, value: secondaryBackground)),
HighlightRule(pattern: horizontalRuleRegex, formattingRule: TextFormattingRule(key: .foregroundColor, value: lighterColor)),
HighlightRule(pattern: unorderedListRegex, formattingRule: TextFormattingRule(key: .foregroundColor, value: lighterColor)), |
swift | // Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
/// Decorates types which are backed by a Foundation reference type.
///
/// All `ReferenceConvertible` types are hashable, equatable, and provide description functions.
public protocol ReferenceConvertible : CustomStringConvertible, CustomDebugStringConvertible, Hashable, Equatable {
associatedtype ReferenceType : NSObject, NSCopying
}
|
swift | /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
/// THE SOFTWARE.
|
swift |
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 configuration to create the new scene with.
return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role)
}
func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set<UISceneSession>) {
// Called when the user discards a scene session.
// If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions. |
swift | fatalError("init(coder:) has not been implemented")
}
}
class HomeRefreshView: UIView {
@IBOutlet weak var tipView: UIView! |
swift | // MockDTInitialize.swift
// DitoSDK Tests
//
// Created by brennobemoura on 07/01/21.
//
@testable import DitoSDK
extension Dito {
static func identify(id: String,
data: DitoUser,
sha1Signature: String = Dito.signature, |
swift | //
// 1.swift
// advent-of-code-2018
//
// Created by Lockhart, Alex on 01/12/2018.
// Copyright © 2018 Lockhart, Alex. All rights reserved.
//
import Foundation |
swift | // copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
swift | struct Room: Codable {
let status: Status
let id: String
let members: [String]
init(status: Status, id: String, members: [String] = []) {
self.status = status
self.id = id |
swift | if isOn {
config.newCPUFlag(flag)
} else {
config.removeCPUFlag(flag)
} |
swift | struct Charges: Codable {
let value: Int
let recovers: Int
}
|
swift | cgContext.addPath(path)
cgContext.drawPath(using: drawingMode)
}
}
}
}
#endif |
swift | // Release any resources associated with this scene that can be re-created the next time the scene connects.
// The scene may re-connect later, as its session was not necessarily discarded (see `application:didDiscardSceneSessions` instead).
}
func sceneDidBecomeActive(_ scene: UIScene) {
// Called when the scene has moved from an inactive state to an active state.
// Use this method to restart any tasks that were paused (or not yet started) when the scene was inactive.
} |
swift | class LoginViewController: StoryboardIdentifiableViewController {
var presenter: LoginPresenter?
@IBOutlet weak var usernameField: UITextField?
@IBOutlet weak var passwordField: UITextField?
@IBAction private func login(_ sender: UIButton) {
presenter?.login(username: usernameField?.text, password: passwordField?.text)
self.dismiss(animated: true, completion: nil) |
swift |
import XCTest
class APITests: XCTestCase {
}
|
swift |
/// Combine functions.
///
/// - Parameters:
/// - f: First function that will be apply on parameter.
/// - g: Second function that will be apply on the result of first function.
/// - Returns: Function combined from first and second function.
func >>> <A, B, C>(_ f: @escaping (A) -> B, _ g: @escaping (B) -> C) -> (A) -> C {
return { input in
g(f(input))
}
}
|
swift | }
/// 添加键盘工具栏
func addTopBar() {
let btn = UIButton(type: UIButtonType.custom)
btn.setTitle("完成", for: UIControlState.normal)
btn.titleLabel?.font = FontSize16
btn.backgroundColor = UIColor.black
btn.frame = CGRect(x: 0, y: 0, width: KScreenWidth, height: 44)
btn.addTarget(self, action: #selector(closeKeyboardAction), for: UIControlEvents.touchUpInside)
self.inputAccessoryView = btn
}
@objc private func closeKeyboardAction() {
self.resignFirstResponder()
} |
swift | )
== (foo(
firstFuncCallArg,
second: secondFuncCallArg,
third: thirdFuncCallArg,
fourth: fourthFuncCallArg
)))
let x = |
swift | _webRTCClient?.drainMessageQueue()
}
}
//MARK: WebRTCClientDelegate
extension AppViewModel: WebRTCClientDelegate { |
swift | //
// Extensions.swift
// DoomFire
//
// Created by Adriano Rodrigues Vieira on 10/04/21.
//
import Foundation
extension Bundle {
func decode<T: Codable>(_ filename: String) -> T {
guard let url = self.url(forResource: filename, withExtension: nil) else { |
swift | }
let makersReducer = Reducer<WithSharedState<MakersState>, MakersAction, MakersEnvironment> {
state, action, _ in
switch action {
case .onAppear:
state.local.makersList = Makers.makersList
return .none
case .backButtonTapped: |
swift | case i860
case powerpc
public init(legacyCPUType: cpu_type_t) {
switch legacyCPUType {
case CPU_TYPE_ANY:
self = .any |
swift | }
func makeUIView(context: Context) -> UIPageControl {
let control = UIPageControl()
control.numberOfPages = numberOfPages
control.addTarget(context.coordinator, action: #selector(Coordinator.updateCurrentPage(sender:)), for: .valueChanged)
|
swift | import Crypto
@testable import App
public class AppTests: XCTestCase {
func testBCrypt() {
do { |
swift |
func box(_ float: Float) throws -> NSObject {
guard !float.isInfinite && !float.isNaN else {
guard case let .convertToString(positiveInfinity: posInfString,
negativeInfinity: negInfString,
nan: nanString) = self.options.nonConformingFloatEncodingStrategy else { |
swift | return field
}
sv.addSubview(field)
field.snp.makeConstraints { (make) in
maker(make)
}
return field
}
} |
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 pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}
func applicationDidEnterBackground(_ application: UIApplication) {
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. |
swift | func redirect(_ value: KhalaNode) -> KhalaNode {
return filters.reduce(value) { (result, filter) -> KhalaNode in
return filter.closure(result)
}
}
|
swift | *
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* * Neither the name of CosmicMind nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission. |
swift | self.id = json["id"].stringValue
}
}
open class MarkerParam: ParameterEncodable {
let action: Marker.Action
let itemType: Marker.ItemType
let itemIds: [String]
init(action: Marker.Action, itemType: Marker.ItemType, itemIds:[String]) {
self.action = action
self.itemType = itemType
self.itemIds = itemIds
}
open func toParameters() -> [String : Any] { |
swift |
public static func error(_ items: Any..., file: String = #file, function: StaticString = #function, line: Int = #line) {
self.log(items, file: file, function: function, line: line, type: .error)
}
public static func debug(_ items: Any..., file: String = #file, function: StaticString = #function, line: Int = #line) { |
swift | var progressViewStyle: UIProgressView.Style
var progress: Float
@available(iOS 5.0, *)
var progressTintColor: UIColor?
@available(iOS 5.0, *) |
swift | if addShaddow {
self.layer.masksToBounds = false
self.layer.shadowColor = self.shadowColor.cgColor
self.layer.shadowOpacity = Float(self.shadowOpacity)
self.layer.shadowOffset = CGSize(width: self.offSetWidth, height: self.offSetHeight)
self.layer.shadowRadius = self.shadowRadius
} else {
self.layer.shadowOpacity = 0
}
}
public func addLeftViewBox() {
let paddingView = UIView(frame: CGRect(x: 0, y: 0, width: self.leftViewWidth, height: self.frame.height)) |
swift | //
// Created by saeed on 11/12/21.
//
import Foundation
enum Vibration: String {
case short = "s"
case long = "l"
case unknown = "" |
swift | do {
let rx = try NSRegularExpression(pattern: regex, options: [.caseInsensitive])
var matches: [NSTextCheckingResult] = []
let limit = 300000
|
swift | func getBegin() -> Int {
if !hasValue() {
return 0
}
let fbeOptionalOffset = Int(readUInt32(offset: fbeOffset + 1))
if fbeOptionalOffset <= 0 {
assertionFailure("Model is broken!")
return 0 |
swift | showDialog(title: "Error", message: "No location found.")
return false
}
if isSimulated {
startGeoCoordinates = getMapViewCenter()
} else { |
swift |
protocol ExamplePresenterOutput: class {
}
final class ExamplePresenter: ExampleViewOutput, ExampleInteractorOutput {
weak var view: ExampleViewInput?
var interactor: ExampleInteractorInput!
var output: ExamplePresenterOutput!
// MARK: - View output
func viewIsReady() {
|
swift | public var isEmpty: Bool {
return self.rows == 0 && self.columns == 0
}
}
// MARK: Dimensions Equality
public func == (left: Dimensions, right: Dimensions) -> Bool {
return left[0] == right[0] && left[1] == right[1]
}
// MARK: Dimensions Tuple Equality
public func == (left: Dimensions, right: (Int, Int)) -> Bool { |
swift | cellObjs += [cellObj]
}
if true {
let cellObj = SectionCellViewModel()
cellObj.delegate = delegate
|
swift | .package(url: "https://github.com/Subito-it/Bariloche", .branch("master")),
.package(url: "https://github.com/tcamin/http.git", .branch("master")),
.package(url: "https://github.com/tcamin/Vaux", .branch("cachi")),
],
targets: [ |
swift | }
func modificationDateOfFile(atPath path: String) throws -> Date {
let attributes = try attributesOfItem(atPath: path)
return (attributes[.modificationDate] as? Date) ?? .init() |
swift | let hash = try self.getContentHash(tokenId: tokenId)
return hash
}
let resolverAddress = try resolver(tokenId: tokenId)
let resolverContract = try super.buildContract(address: resolverAddress, type: .resolver)
let ensKeyName = self.fromUDNameToEns(record: key)
|
swift | static func from(_ vi: TickerViewItem) -> TickerDTO {
return TickerDTO(id: vi.id, ticker: vi.ticker, currencyCode: vi.currencyCode)
}
static func from(_ data: [String: Any]) -> TickerDTO {
let id = data["id"] as? String ?? "" |
swift | func testBinomialProportionConfidenceInterval() {
let correct_lower = 0.5838606324
let correct_upper = 0.7914774104
let results = StatsHelper.binomialProportionCondifenceInterval(wins: 30,
losses: 13,
confidence: 0.87)
XCTAssert(fuzzyFloatEquals(a: results.lower, b: correct_lower))
XCTAssert(fuzzyFloatEquals(a: results.upper, b: correct_upper)) |
swift | 指定した外部アプリがインストールされているか判定する
*/
func canOpenExternalApp(url: String) -> Bool {
if let url = URL(string: url) {
return canOpenURL(url)
} else {
return false
}
}
/**
外部アプリを開く |
swift | }))
return action
}
func connectChoice<T>(choices: [T], description: (T) -> String = { String(describing: $0) }) -> Observable<T?> {
let action = PublishSubject<T?>()
let cancelAction = UIAlertAction(title: "Cancel", style: .cancel, handler: { _ in action.onSuccess(nil) })
let actions = choices.map { element in
UIAlertAction(title: description(element), style: .default, handler: { _ in action.onSuccess(element) }) |
swift | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
import UIKit
class FeedCell: BaseCell {
// TODO: This will be handled with view model
var post: Post? |
swift | @IBOutlet weak var courseCredit: UILabel!
@IBOutlet var starArray: [UIImageView]!
@IBOutlet weak var money: UILabel!
@IBOutlet weak var classHour: UILabel!
@IBOutlet weak var cancelBtn: UIButton! |
swift | guard let language = inputMode.primaryLanguage else { continue }
if Locale.tap_primaryLocaleIdentifier(from: language) == self.preferredKeyboardLanguage {
return inputMode
} |
swift | try application.display(in: rect)
}
// sleep to save energy
let frameDuration = SDL_GetTicks() - startTime
if frameDuration < frameInterval {
SDL_Delay(frameInterval - frameDuration)
}
}
}
do { try main() }
catch let error as SDLError {
print("Error: \(error.debugDescription)") |
swift | ///
/// Special userinfos.
///
struct UserInfo {
///
/// Keys of the CloudNoteService for the user info of a notification.
///
struct CloudNoteService {
///
/// The key for the error message.
///
public static let errorMessage = "ErrorMessage" |
swift | // RemembArt
//
// Created by Roman Cheremin on 28/11/2019.
// Copyright © 2019 Daria Cheremina. All rights reserved.
// |
swift | // Created by Anthony Latsis on 2/20/18.
// Copyright © 2018 Anthony Latsis. All rights reserved.
//
import UIKit.NSLayoutConstraint
public protocol RelationRepresentable {
func relation() -> NSLayoutConstraint.Relation
} |
swift | // tipCalc
//
// Created by Akash Gheewala on 12/11/18.
// Copyright © 2018 Akash Gheewala. All rights reserved.
//
import UIKit
class LightTheme: ThemeProtocol {
var mainFontName: String = "Silom"
var backgroundOne: UIColor = UIColor(named: "backgroundLight")!
var backgroundTwo: UIColor = UIColor(named: "backgroundLightTwo")!
var text: UIColor = UIColor(named: "textLight")!
}
|
swift | * Copyright 2019-2020 Datadog, Inc.
*/
import XCTest
@testable import Datadog
extension RUMDataUSR: EquatableInTests {}
class RUMUserInfoProviderTests: XCTestCase {
private let userInfoProvider = UserInfoProvider()
private lazy var rumUserInfoProvider = RUMUserInfoProvider(userInfoProvider: userInfoProvider) |
swift | func testMapToQuarterlyMobileDataUsages() {
let testData1 = "{}"
let result1 = DataMappingServices.getInstance().mapToQuarterlyMobileDataUsages(json: testData1)
XCTAssertEqual(result1.count ,0, "MapToQuarterlyMobileDataUsages is wrong")
let testData2 = "{\"success\": true, \"result\": {\"resource_id\": \"a807b7ab-6cad-4aa6-87d0-e283a7353a0f\", \"fields\": [{\"type\": \"int4\", \"id\": \"_id\"}, {\"type\": \"text\", \"id\": \"quarter\"}, {\"type\": \"numeric\", \"id\": \"volume_of_mobile_data\"}], \"records\": [{\"volume_of_mobile_data\": \"18.47368\", \"quarter\": \"2018-Q2\", \"_id\": 56}], \"offset\": 55, \"total\": 56}}"
let result2 = DataMappingServices.getInstance().mapToQuarterlyMobileDataUsages(json: jsonSerialization(str: testData2))
XCTAssert(result2.count == 1)
}
//todo |
swift | }
func showPasswordGenerationDialog(success: (() -> Void)) {
let alertController = UIAlertController(title: "Generate Password?", message: "iOS can generate an absurdly secure password for you and store it in your keychain.", preferredStyle: .Alert)
|
swift | troll, // Rastakhan's Rumble
dalaran, // rise of the shadows
uldum, // Saviors of Uldmu
wild_event,
dragons, // Descent of Dragons
year_of_the_dragon,
black_temple, |
swift | }
func sceneWillResignActive(_ scene: UIScene) {
// Called when the scene will move from an active state to an inactive state.
// This may occur due to temporary interruptions (ex. an incoming phone call).
}
func sceneWillEnterForeground(_ scene: UIScene) { |
swift | func signOut()
}
protocol AuthStoreReading: AnyObject {
var isSignedIn: Bool { get }
var passcode: String? { get }
var userDisplayName: String { get }
}
class AuthStore: NSObject {
static let shared: AuthStoreWriting = AuthStoreFactory().makeAuthStore()
}
|
swift | * limitations under the License.
*/
import UIKit
import Backpack
class SettingsViewController: UITableViewController {
@IBOutlet weak var closeButton: UIBarButtonItem!
@IBOutlet weak var enableThemeSwitch: Switch!
var showThemeList: Bool = false
@IBOutlet var selectableCells: [BPKTableViewSelectableCell]!
override func viewDidLoad() {
super.viewDidLoad() |
swift | public let requestId: RequestId
public init(enqueuedBucket: EnqueuedBucket, workerId: WorkerId, requestId: RequestId) {
self.enqueuedBucket = enqueuedBucket
self.workerId = workerId
self.requestId = requestId
}
public var description: String { |
swift | cardIcon.alpha = 0.8
cardIcon.contentMode = .scaleAspectFit
mainView.addSubview(cardIcon)
cardLabel = UILabel()
cardLabel.textColor = .white
cardLabel.font = UIFont.boldSystemFont(ofSize: 16.0)
cardLabel.textAlignment = .center
cardLabel.text = "다른 결제수단"
mainView.addSubview(cardLabel) |
swift | import SwiftUI
import SwiftUIFlux
// MARK:- Shared View
struct HomeView: View {
#if targetEnvironment(macCatalyst)
var body: some View {
SplitView()
}
#else
var body: some View {
TabbarView()
}
#endif
} |
swift | public static let notImplemented: HttpStatus = .init(501, text: "Not Implemented")
public static let badGateway: HttpStatus = .init(502, text: "Bad Gateway")
public static let serviceUnavailable: HttpStatus = .init(503, text: "Service Unavailable")
public static let gatewayTimeout: HttpStatus = .init(504, text: "Gateway Timeout")
public static let hTTPVersionNotSupported: HttpStatus = .init(505, text: "HTTP Version not supported")
public static let variantAlsoNegotiates: HttpStatus = .init(506, text: "Variant Also Negotiates")
public static let insufficientStorage: HttpStatus = .init(507, text: "Insufficient Storage")
public static let loopDetected: HttpStatus = .init(508, text: "Loop Detected") |
swift | testCase(DivTests.allTests),
testCase(MainTests.allTests),
testCase(LabelTests.allTests),
testCase(PreTests.allTests),
testCase(PTests.allTests),
testCase(SectionTests.allTests),
testCase(TextTests.allTests),
testCase(CompositeElementsTests.allTests),
testCase(FactoryElementsTests.allTests),
testCase(TextareaTests.allTests),
testCase(BodyTests.allTests),
testCase(HeadTests.allTests),
testCase(HtmlTests.allTests),
testCase(LinkTests.allTests),
testCase(MetaTests.allTests), |
swift | extension Outer5B {
class Inner : OtherOuter5B.Super {}
}
extension OtherOuter5B {
class Super {}
}
extension Outer5B.Inner {}
///
enum Outer5C {}
enum OtherOuter5C {} |
swift | // ImageDocker
//
// Created by Kelvin Wong on 2021/5/26.
// Copyright © 2021 nonamecat. All rights reserved.
//
import Cocoa
class ImageMetaViewController : NSViewController {
@IBOutlet weak var scrollView: NSScrollView!
@IBOutlet weak var tableView: DarkTableView!
required init?(coder: NSCoder) { |
swift | ///
@propertyWrapper
public struct LazyInject<T> {
private var _value: T?
public var wrappedValue: T {
mutating get { value() }
}
private let tag: String?
|
swift | // Created by Skye Freeman on 1/27/17.
// Copyright © 2017 Skye Freeman. All rights reserved.
//
import UIKit
public extension UIBarButtonItem {
@discardableResult func onTap(completion: @escaping OTStandardClosure) -> Self {
touchHandler?.onTap = completion
return self
}
convenience init(barButtonSystemItem: UIBarButtonSystemItem, onTap: @escaping OTStandardClosure) { |
swift |
if (j == 0) && (first) {
first = false
}
|
swift |
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
NetGuard().loadNetGuard()
return true |
swift | case architecture = "Architecture"
case hypervisor = "Hypervisor"
case instanceStoreAvailability = "InstanceStoreAvailability"
case networkInterface = "NetworkInterface"
case storageInterface = "StorageInterface"
case virtualizationType = "VirtualizationType"
public var description: String { return self.rawValue }
}
public enum RecommendationPreferenceName: String, CustomStringConvertible, Codable, _SotoSendable {
case enhancedInfrastructureMetrics = "EnhancedInfrastructureMetrics"
case inferredWorkloadTypes = "InferredWorkloadTypes"
public var description: String { return self.rawValue } |
swift | import UIKit
import Reachability
import UserNotifications
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterDelegate {
var window: UIWindow?
let reachability = Reachability()
var internetAlert: UIAlertController?
|