Skip to content

Instantly share code, notes, and snippets.

View hsleedevelop's full-sized avatar
🔥

HS Lee hsleedevelop

🔥
View GitHub Profile
import Foundation
extension String {
//Know if self is only composed by numbers
var isNumber: Bool {
return !self.isEmpty && CharacterSet.decimalDigits.isSuperset(of: CharacterSet(charactersIn: self))
}
}
//Struct to check Regular Expresions
@hsleedevelop
hsleedevelop / Swift 3: How to implement a service extension.swift
Created September 7, 2022 13:00 — forked from barbaramartina/Swift 3: How to implement a service extension.swift
Swift 3: implement a service extension and download an image attachment.
//
// NotificationService.swift
// Service
//
// Created by Barbara Rodeker on 28/09/16.
// Copyright © 2016 Barbara Rodeker. All rights reserved.
//
import UserNotifications
@hsleedevelop
hsleedevelop / AuthService.swift
Created June 27, 2022 05:08 — forked from NunciosChums/AuthService.swift
Moya + renewal token when Unauthorized(401)
import Foundation
import Moya
import RxSwift
/// 인증 관련 API
final class AuthService: BaseService<AuthAPI> {
static let shared = AuthService()
private override init() {}
/// 토큰 재발급
@hsleedevelop
hsleedevelop / Safer SwiftUI Environment.md
Created June 15, 2022 04:49 — forked from anandabits/Safer SwiftUI Environment.md
Towards a safer SwiftUI environment

Towards a safer SwiftUI environment

Swift UI's @EnvironmentObject is currently prone to runtime errors. If a view uses an environment object of a type that was not injected using environmentObject a fatalError occurs. This document sketches a design that would support compile-time checking of environment object usage. It requires a few language enhancements.

Tuple intersection types

Swift's protocol composition types such as Protocol1 & Protocol2 are a form of intersection types. Other forms of intersection types are possible. For example, Flow has object intersection types. Tuple intersection types for Swift would be very similar to these.

Below, you can see the examples in the Flow documentation converted to Swift's tuples:

import Combine
import SwiftUI
@dynamicMemberLookup public protocol ViewModelBinding {
associatedtype State
associatedtype Input
var state: State { get }
mutating func bind(with input: PassthroughSubject<Input, Never>)
}
@hsleedevelop
hsleedevelop / SwiftUI Interface.swift
Created June 15, 2022 04:31 — forked from Cosmo/SwiftUI Interface.swift
SwiftUI Interface (Module Names removed)
// swift-interface-format-version: 1.0
// swift-compiler-version: Apple Swift version 5.1.1 (swiftlang-1100.2.274.2 clang-1100.2.32.1)
// swift-module-flags: -target arm64e-apple-ios13.2 -enable-objc-interop -enable-library-evolution -swift-version 5 -enforce-exclusivity=checked -Osize -module-name SwiftUI
import Combine
import CoreData
import CoreFoundation
import CoreGraphics
import CoreText
import Darwin
import Foundation
@hsleedevelop
hsleedevelop / UI Testing - Mocking Network Data
Created June 2, 2022 02:57 — forked from joemasilotti/ UI Testing - Mocking Network Data
Xcode UI Testing - How to mock network data
.
@hsleedevelop
hsleedevelop / XcodeBuildSettingsReference.md
Created June 2, 2022 02:18 — forked from NSExceptional/XcodeBuildSettingsReference.md
The Xcode Build Settings Reference in a searchable document, as of Xcode 8.3.2

Build settings reference

Active Build Action (ACTION)

A string identifying the build system action being performed.

Additional SDKs (ADDITIONAL_SDKS)

The locations of any sparse SDKs that should be layered on top of the one specified by Base SDK (SDKROOT). If more than one SDK is listed, the first one has highest precedence. Every SDK specified in this setting should be a "sparse" SDK, for example, not an SDK for an entire macOS release.

Alternate Install Group (ALTERNATE_GROUP)

//
// WKWebView+Rx.swift
// RxGround
//
// Created by eyemac on 2017. 9. 2..
// Copyright © 2017년 rollmind. All rights reserved.
//
import WebKit
import RxSwift
@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