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
typealias DataSource = UITableViewDiffableDataSource<Int, String>
typealias SnapShot = NSDiffableDataSourceSnapshot<Int, String>
private var dataSource: DataSource!
@IBOutlet weak var tableView: UITableView!
override func viewDidLoad() {
super.viewDidLoad()
@hsleedevelop
hsleedevelop / functions.sh
Last active August 12, 2022 12:36
AlfredGist/functions.sh - python3
#!/bin/bash
OUR_DIR=$(cd $(dirname "$0"); pwd)
[[ ! -d "$PREF_DIR" ]] && mkdir -p "$PREF_DIR" 2>/dev/null
function echo_start_items() {
echo '<?xml version="1.0"?>'
echo '<items>'
}
@hsleedevelop
hsleedevelop / DialogOneButtonView.swift
Created August 12, 2022 12:29
Representable Implements
//
// DialogOneButtonView.swift
//
// Created by HS Lee on 2022/08/08.
//
import Foundation
import UIKit
import SwiftUI
@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
.