Skip to content

Instantly share code, notes, and snippets.

View hsleedevelop's full-sized avatar
🔥

HS Lee hsleedevelop

🔥
View GitHub Profile
extension XCUIElement {
func clearText(andReplaceWith newText:String? = nil) {
tap()
press(forDuration: 1.0)
var select = XCUIApplication().menuItems["Select All"]
if !select.exists {
select = XCUIApplication().menuItems["Select"]
}
//For empty fields there will be no "Select All", so we need to check
//
// UPCarouselFlowLayout.swift
// UPCarouselFlowLayoutDemo
//
// Created by Paul Ulric on 23/06/2016.
// Copyright © 2016 Paul Ulric. All rights reserved.
//
// https://github.com/ink-spot/UPCarouselFlowLayout/blob/master/UPCarouselFlowLayout/UPCarouselFlowLayout.swift
import UIKit
class ShopFilterParams: NSObject, Codable, DictionaryMapping {
private var config: [String: Any]?
private var defaults: [String: Any]?
private var list: [String: Any]?
var showAreaFilter: Bool?
var showServiceFilter: Bool?
var defaultAreaId: String?
var defaultService: String?
@hsleedevelop
hsleedevelop / gist:4c3181b9f596f8b32d621f6621fdd341
Last active October 8, 2020 08:57
UITableViewAlertForLayoutOutsideViewHierarchy
https://developer.apple.com/forums/thread/120790
Still an issue in newly released 13.4.
My main problem is when a table is in split overlay mode (e.g. by default on iPhone X/XR/11) but hidden the rotation causes UITableView layoutSubviews which throws UITableViewAlertForLayoutOutsideViewHierarchy despite the table not being in the window.
Apple please see FB7306484
do {
let output = try decoder.decode(FlanetNotification.self, from: data)
App.ui.alert(message:"parsed!!!", callback: nil)
} catch DecodingError.dataCorrupted(let context) {
App.ui.alert(message: context.debugDescription, callback: nil)
} catch DecodingError.keyNotFound(let key, let context) {
App.ui.alert(title: "Key '\(key)' not found:", message: context.debugDescription, callback: nil)
App.ui.alert(title: "codingPath: \(context.codingPath)", message: context.debugDescription, callback: nil)
} catch DecodingError.valueNotFound(let value, let context) {
print("Value '\(value)' not found:", context.debugDescription)
@hsleedevelop
hsleedevelop / subclassing-uiviewcontrollers.swift
Last active April 11, 2022 01:03
Using Generics to simplify subclassing UIViewController’s view
//refs: https://codeinswift.io/using-generics-to-simplify-subclassing-uiviewcontrollers-view-860c90852e27
class ViewController<UI: UIView>: UIViewController {
let ui = UI(frame: UIScreen.main.bounds)
override func loadView() {
self.view = ui
}
}
@hsleedevelop
hsleedevelop / composableExample.kt
Last active April 11, 2022 02:10
composable example
@Composable
fun ProfileInput(
profile: UserProfileUi,
modifier: Modifier = Modifier
) {
Scaffold(modifier = modifier) {
// Require to go at the next input from the keyboard.
val focusManager = LocalFocusManager.current
LazyColumn {
if (profile.qrCode != null) {

Debugging the Swift Toolchain

Use these steps to debug components of the Swift toolchain. This allows you to see Swift's source code from the debugger – instead of disassembly. The debugger can also provide some variable names and values. This has been initially tested with libswiftCore.dylib.

These instructions were updated as of Swift 5.2.1.

Prerequisites

@hsleedevelop
hsleedevelop / helpers.swift
Created June 2, 2022 02:02 — forked from kastiglione/helpers.swift
Swift helpers, and the lldb setup to use them. Presented @ SLUG https://speakerdeck.com/kastiglione/advanced-debugging-and-swift
extension UIView {
/// Example: call someView.nudge(0, 30)
func nudge(_ dx: CGFloat, _ dy: CGFloat) {
self.frame = self.frame.offsetBy(dx: dx, dy: dy)
CATransaction.flush()
}
}
extension UIView {
/// Example: po UIView.root
//
// WKWebView+Rx.swift
// RxGround
//
// Created by eyemac on 2017. 9. 2..
// Copyright © 2017년 rollmind. All rights reserved.
//
import WebKit
import RxSwift