Skip to content

Instantly share code, notes, and snippets.

import Foundation
import Combine
let publisher = ["A", "B", "C", "D"].publisher
publisher
.contains("C")
.sink {
print($0) // true
}
@paigeshin
paigeshin / Data+Extensions.swift
Created October 21, 2022 14:40 — forked from nbasham/Data+Extensions.swift
Get a random date between two values. Swift 4.2+ uses Random(in:).
import Foundation
extension Date {
static func randomBetween(start: String, end: String, format: String = "yyyy-MM-dd") -> String {
let date1 = Date.parse(start, format: format)
let date2 = Date.parse(end, format: format)
return Date.randomBetween(start: date1, end: date2).dateString(format)
}
@paigeshin
paigeshin / convert.swift
Created October 17, 2022 09:58 — forked from SatoTakeshiX/convert.swift
Take capture a view by SwiftUI
//
// ContentView.swift
// TryGeometryReader
//
// Created by satoutakeshi on 2019/12/07.
// Copyright © 2019 satoutakeshi. Licensed under MIT.
//
import SwiftUI
@paigeshin
paigeshin / sign_in_with_apple.yml
Created September 3, 2022 08:22 — forked from liamnichols/sign_in_with_apple.yml
Localisations of the "Sign in with Apple" string taken from Xcode 11.1
SIGN_IN_WITH_APPLE:
- de: Mit Apple anmelden
- he: התחברות באמצעות Apple
- en_AU: Sign in with Apple
- ar: تسجيل الدخول باستخدام Apple
- el: Σύνδεση μέσω Apple
- ja: Appleでサインイン
- en: Sign in with Apple
- uk: Увійти з Apple
- es_419: Iniciar sesión con Apple
func test_should_display_error_message_for_missing_required_fields() {
let app = XCUIApplication()
continueAfterFailure = false
let loginPageObject = LoginPageObject(app: app)
app.launch()
let usernameTextField = loginPageObject.usernameTextField
usernameTextField.tap()
usernameTextField.typeText("")
import Foundation
import XCTest
class LoginPageObject {
var app: XCUIApplication
init(app: XCUIApplication) {
self.app = app
}
func test_should_display_error_message_for_missing_required_fields() {
let app = XCUIApplication()
continueAfterFailure = false
app.launch()
let usernameTextField = app.textFields["usernameTextField"]
usernameTextField.tap()
usernameTextField.typeText("")
let passwordTextField = app.textFields["passwordTextField"]
// View
var body: some View {
TextField("User name", text: $loginVM.username)
.accessibilityIdentifier("usernameTextField")
}
// UI Testing Mapping
let usernameTextField = app.textFields["usernameTextField"]
usernameTextField.tap()
usernameTextField.typeText("")
extension UITableView {
func register(_ type: UITableViewCell.Type) {
let className = String(describing: type)
register(UINib(nibName: className, bundle: nil), forCellReuseIdentifier: className)
}
func dequeueReusableCell<T>(_ type: T.Type) -> T? {
let className = String(describing: type)
return dequeueReusableCell(withIdentifier: className) as? T
// Register Cell
tableView.register(UINib(nibName: "MyCell", bundle: nil), forCellReuseIdentifier: "MyCell")
// Dequeue Cell
let cell = tableView.dequeueReusableCell(withIdentifier: "MyCell") as! MyCell