Skip to content

Instantly share code, notes, and snippets.

View hhhello0507's full-sized avatar
💭
🗡️

이강현 hhhello0507

💭
🗡️
  • Daegu, South Korea
View GitHub Profile
//
// UINavigationControllerExt.swift
// DodamDodam
//
// Created by hhhello0507 on 7/28/24.
//
import UIKit
extension UINavigationController: UIKit.UIGestureRecognizerDelegate {
if [[ "$(uname -m)" == arm64 ]]; then
export PATH="/opt/homebrew/bin:$PATH"
fi
if which periphery > /dev/null; then
cd ../../
pwd
periphery scan --workspace ./Seugi.xcworkspace --schemes Seugi-iOS --targets Seugi-iOS DIContainer Feature Component Core Network Local --format xcode --report-exclude **/Derived/*.swift
# Domain is not included
import OSLog
extension OSLog {
static let subsystem = Bundle.main.bundleIdentifier!
static let network = OSLog(subsystem: subsystem, category: "Network")
static let debug = OSLog(subsystem: subsystem, category: "Debug")
static let info = OSLog(subsystem: subsystem, category: "Info")
static let error = OSLog(subsystem: subsystem, category: "Error")
}
import Foundation
public extension StringProtocol {
subscript(offset: Int) -> Character { self[index(startIndex, offsetBy: offset)] }
subscript (bounds: CountableRange<Int>) -> String {
let start = index(startIndex, offsetBy: bounds.lowerBound)
let end = index(startIndex, offsetBy: bounds.upperBound)
public extension Comparable {
func clamped(to limits: ClosedRange<Self>) -> Self {
return min(max(self, limits.lowerBound), limits.upperBound)
}
}
import Combine
import SwiftUI
public extension Publisher {
func ignoreError() -> AnyPublisher<Output, Never> {
return self.catch { _ in
Empty<Output, Never>()
}
.eraseToAnyPublisher()
}
import SwiftUI
public struct ScrollOffsetPreferenceKey: PreferenceKey {
public static var defaultValue: CGFloat = 0
public static func reduce(value: inout CGFloat, nextValue: () -> CGFloat) {
value += nextValue()
}
}
import SwiftUI
import UIKit
public extension View {
func hideKeyboardWhenTap() -> some View {
self.onTapGesture(perform: hideKeyboard)
}
func hideKeyboard() {
UIApplication.shared.sendAction(#selector(UIResponder.resignFirstResponder), to: nil, from: nil, for: nil)
import SwiftUI
public extension View {
@ViewBuilder
func onReadSize(_ perform: @escaping (CGSize) -> Void) -> some View {
self.customBackground {
GeometryReader { geometryProxy in
Color.clear
.preference(key: SizePreferenceKey.self, value: geometryProxy.size)
}
import Foundation
import Moya
// NetRunner 클래스에서 사용.
// 원래 NetRunner는 BaseEndpoint를 준수 받는 Endpoint (e.g. MealEndpoint, AIEndpoint)를 Generic하게 사용하고 있었음.
// 이런 방식으로 하니 각 Endpoint 별로 NetRunner를 만들어야 함.
//
// 이 프로젝트에서는 각 Endpoint 별로 다른 NetRunner를 쓸 필요성을 못 느낌.
// 따라서 NetRunner는 Generic하게 사용하는 오브젝트를 알 필요가 없음.